Guest User

Untitled

a guest
Jul 12th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. @implementation ThirdView
  2.  
  3. @synthesize ball;
  4. @synthesize ball2;
  5.  
  6.  
  7. -(void) onTimer {
  8. ball.center = CGPointMake(ball.center.x+pos.x,ball.center.y+pos.y);
  9.  
  10. if (ball.center.x > 320 || ball.center.x < 0)
  11. pos.x = -pos.x;
  12. if (ball.center.y > 460 || ball.center.y < 0)
  13. pos.y = -pos.y;
  14.  
  15. }
  16.  
  17. -(void) onTimer2 {
  18. ball2.center = CGPointMake(ball2.center.x+pos2.x,ball2.center.y+pos2.y);
  19.  
  20. if (ball2.center.x > 320 || ball2.center.x < 0)
  21. pos2.x = -pos2.x;
  22. if (ball2.center.y > 460 || ball2.center.y < 0)
  23. pos2.y = -pos2.y;
  24.  
  25. }
  26.  
  27. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30.  
  31. pos = CGPointMake(14.0,7.0);
  32.  
  33. [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector (onTimer) userInfo:nil repeats:YES];
  34.  
  35. pos2 = CGPointMake(14.0,7.0);
  36.  
  37. [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector (onTimer2) userInfo:nil repeats:YES];
  38.  
  39. }
  40.  
  41.  
  42. - (IBAction)buttonClick {
  43. [self.parentViewController dismissModalViewControllerAnimated:YES];
  44. }
  45.  
  46. @end
Add Comment
Please, Sign In to add comment