nstimer - What is the best way to make a bouncing ball animation with infinite loop on iPhone? -


I am developing an iPhone game in which the birds bounce like this game:

I set Images of animating winged wings like this have been done:

  [IMGbird [i] set animation images: bird Arrow Constant]; [IMGbird [I] Set Animation Duration: 1.0]; [Imgbird [i] start-up];  

Now how do I use an NSTimer to set fire to every 0.03 second to move the bird, which connects IGBird [I] to X or Y coordinate with 1 / Decreases.

I have learned about doing it this way from here. Http: // icodeblog com / 2008/10/28 / iphone-programming-tutorial-animating-a-ball-using-an-nstimer /

But the point is that as soon as any other timer Ship the bird in the same way) returns to the fire and the original speed because I stop the ship from moving forward.

Is there a better way to move the bird except NSTIMER?

The movement of birds is an infinite loop.

You have to import core graphics and quartzakor framework in the project.

Add these lines to the top of your file.

  #import & lt; Quartzcore / Quartzcour & gt; #import & lt; Core Graphics / Core Graphics H & gt;  

...

  UIImageView * bird = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "bird2.png"]]; CALayer * b = bird.layer; // Create a keyframe animation to follow the path to the approximate point. CAKeyframeAnimation * Animation = [CAKeyframeAnimation animationWithKeyPath: @ "scale"]; Animation. RemovedOnCompletion = No; // Create path for bounce CGMutablePathRef thePath = CGPathCreateMutable (); // Start the path on your current location CGPathMoveToPoint (path, NULL, bird.center.x, bird.center.y); CGPathAddLineToPoint (path, faucet, 20, 500.0); / * // Very quiet path system CGMutablePathRef thePath = CGPathCreateMutable (); CGPathMoveToPoint (thePath, Zero, 74.074.0); CGPathAddCurveToPoint (path, faucet, 74.0500.0, 320.0500.0, 320.0, 74.0); CGPathAddCurveToPoint (path, tap, 320.0500.0, 566.0, 500.0, 566.0, 74.0); * / / //animation.rotationMode = kCAAnimationRotateAuto; Animation path = thePath; Animation speed = 0.011; //animation.delegate = self; Animation.repeatcode = 1000000; // Add animation to the layer [b ad animation: animation fork: @ "move"];  

Hope that helps a little.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -