Guest User

Untitled

a guest
Jul 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. }
  2. -(void)addObjectMethod {
  3.  
  4. UIImageView *bomb = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"cloud.png" ]];
  5. [self.view addSubview: bomb];
  6. [bomb release];
  7.  
  8. CGPoint position;
  9. //do the stuff above to create the position
  10. //pick a position anywhere on screen
  11.  
  12. position.x = arc4random() % 360;
  13. position.y = 10;
  14.  
  15. bomb.center = position;
  16.  
  17. if(CGRectIntersectsRect(bomb.frame, me.frame)) {
  18. [self dismissModalViewControllerAnimated:YES];
  19. }
  20.  
  21. [UIView beginAnimations:nil context:NULL];
  22. [UIView setAnimationDelegate:self];
  23. [UIView setAnimationDuration:1.00];
  24. [UIView setAnimationBeginsFromCurrentState:YES];
  25. bomb.frame = CGRectMake(bomb.frame.origin.x, (bomb.frame.origin.y + 510.00), bomb.frame.size.width, bomb.frame.size.height);
  26. [UIView commitAnimations];
  27. }
  28. -(IBAction)tapStart {
  29.  
  30. [NSTimer scheduledTimerWithTimeInterval:(0.8/0.7) target:self selector:@selector(addObjectMethod) userInfo:nil repeats:YES];
  31.  
  32. }
Add Comment
Please, Sign In to add comment