Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

CGPointMake with NSTimer animation stop

kc26518kc26518 Posts: 5New Users
edited July 2012 in iOS SDK Development
I am trying to stop my animation of "sliding" images when they return to their original location (they bounce off the side of the screen), or in other words, I would like to stop them at a specific point. This is the code in the ViewController.m file:


-(void)onTimer { righty.center = CGPointMake(righty.center.x +delta.x, righty.center.y +delta.y); if (righty.center.x > self.view.bounds.size.width+skaterWidth || righty.center.x < -skaterWidth) { delta.x = -delta.x; } if (righty.center.y > self.view.bounds.size.height+skaterWidth || righty.center.y < skaterWidth) { delta.y = -delta.y; }} -(void)onTimer2 { lefty.center = CGPointMake(lefty.center.x -delta2.x, lefty.center.y +delta2.y); if (lefty.center.x > self.view.bounds.size.width+skaterwidth2 || lefty.center.x < -skaterwidth2) { delta2.x = -delta2.x; } if (lefty.center.y > self.view.bounds.size.height+skaterwidth2 || lefty.center.y < skaterwidth2) { delta2.y = -delta2.y; }} -(IBAction)leftfinger:(id)sender{ skaterwidth2= lefty.bounds.size.width/.09; delta2 = CGPointMake(.1, 0.0); timer2 = [NSTimer scheduledTimerWithTimeInterval:.000001 target:self selector:@selector(onTimer2) userInfo:nil repeats:YES]; } -(IBAction)rightfinger:(id)sender { skaterWidth = righty.bounds.size.width/.09; delta = CGPointMake(.1, 0.0); timer = [NSTimer scheduledTimerWithTimeInterval:.000001 target:self selector:@selector(onTimer) userInfo:nil repeats:YES]; }

Replies

  • smithdale87smithdale87 Posts: 4,447iPhone Dev SDK Supporter @ @ @ @ @
    So what does this code do?
  • kc26518kc26518 Posts: 5New Users
    Its part of a game, and It moves two UIImageViews just past the boundary of the screen and then 'bounces' them back in the other direction, but then I need them to stop where they started, instead sliding back and forth infinitely.
Sign In or Register to comment.