0
我想用随机坐标在屏幕上移动一个球。但我的对象绕x轴移动!这里是我的代码:随机移动一个球
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
[UIView setAnimationRepeatCount:1000];
[UIView setAnimationRepeatAutoreverses:YES];
CGFloat x = (CGFloat) random()/(CGFloat) RAND_MAX;
CGFloat y = (CGFloat) random()/(CGFloat) RAND_MAX;
CGPoint squarePostion = CGPointMake(y, x);
blue3.center = squarePostion;
[UIView commitAnimations];
编辑:
我我的代码更改为这可是不行的〜:
CGFloat x = (CGFloat) random()/(CGFloat) RAND_MAX * self.view.bounds.size.width;
CGFloat y = (CGFloat) random()/(CGFloat) RAND_MAX * self.view.bounds.size.height;
CGPoint squarePostion = CGPointMake(y, x);
同样的情况!
请看到我的编辑问题 – 2010-12-03 09:28:38