Guest User

Untitled

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