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