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 { = CGPointMake( +delta.x, +delta.y); if ( > self.view.bounds.size.width+skaterWidth || < -skaterWidth) { delta.x = -delta.x; } if ( > self.view.bounds.size.height+skaterWidth || < skaterWidth) { delta.y = -delta.y; }} -(void)onTimer2 { = CGPointMake( -delta2.x, +delta2.y); if ( > self.view.bounds.size.width+skaterwidth2 || < -skaterwidth2) { delta2.x = -delta2.x; } if ( > self.view.bounds.size.height+skaterwidth2 || < 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]; }


  • 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.