0

I have used

image.animationImages = [NSArray arrayWithObjects:
                         [UIImage imageNamed:@"image1"],
                         [UIImage imageNamed:@"image2"],
                         [UIImage imageNamed:@"image3"],
                         [UIImage imageNamed:@"image4"], nil];


[image setAnimationRepeatCount:1];
image.animationDuration = 1;
[image startAnimating];

but it gives a flip book effect to the animation. What I am looking for is a smooth animation to set each image at given time. I have currently is NSTimers to trigger a method then I have code within the method to set a image and another NSTimer to set another image which is in a method so fourth. It gives the animation I am looking for but the problem I am facing is that I am developing a game and I want when the user pauses the game it stops on the current image it is on. The game runs on a NSTimer which triggers a method. All I do to pause the game is to invalidate the NSTimer.

What approach should I take?

  • 1
    For your game are you set on UIKit or have you considered SpriteKit. SpriteKit can hand a lot of the pausing and un pausing a game for you. – Skyler Lauren Feb 08 '15 at 01:48
  • I am set on UIKit. I havent really looked into SpriteKit. Not sure how I would approach with what I am trying to do with SpriteKit. – Tyler Schoenau Feb 08 '15 at 01:52
  • I think what you want to do can be done, but it will be a lot of work on your end storing what step of the animation your on and how much time has passed for the timer. This will also get a lot more complicated if you have several timers. This link could be of value to you http://stackoverflow.com/questions/347219/how-can-i-programmatically-pause-an-nstimer My recommendation though would be to look at some quick tutorials on SpriteKit though and see if it might be worth your time. Hope that helps. – Skyler Lauren Feb 08 '15 at 02:01
  • Look at SpriteKit for gaming and andvanced animations before you start messing around with timers etc. It can be done with timers thoug but then you are likely to end up with unreadable code, strange side effects etc, especially when the numbers if timers involved increases. – Hermann Klecker Feb 08 '15 at 07:35

0 Answers0