iPhone Development -CGPoint & NSTimer help -
I want to see the ball in a particular area, the problem is that I do not know how the field area and movement The situation here is also this code that I use to move the ball to the whole scene (there is an uiimageview on the ball object view). Thank you.
- {zero} on the timer {ball.center = CGPointMake (ball.center.x + pos.x, ball.center.y + pos.y);
if (ball.center.x> 320 || ball.center.x <0) pos.x = -pos.x; If (ball.center.y> 460 || ball.center.y & lt; 0) pos.y = -pos.y; }
// Apply viewDidload to additional setup after loading the view. - (zero) viewDidLoad {pos = CGPointMake (14.07.0); [NSTimer Scheduled Timer with Time Interface: 0.03 Goal: Self Selector: @Selector (On-Timer) userInfo: Zero repeats: Yes]; Instead of 320 and 460 codecoding,
}
You can use the boundaries of your balls to look forward.
Check the property of bound
UIView
.
Comments
Post a Comment