Question about animation in an iPhone game

Apprentice
Posts: 9
Joined: 2010.11
Post: #1
I'm working on my first iPhone game and all the graphics are almost finished.

All the graphics are done in PNG and all the animation that will be in the game is also ready frame by frame and is also in PNG.

I'm very close to hiring a programmer to do the programming part of the game and my designer wants to know the technical specifications of the iPhone game engine. What he wants to know is how does he have to present the animation or parts of it to the programmer so that the programmer can make the animation work?!

Also how does he need to present sprites?

Also, what about the format? What about frames per second?

Also, if I want to be able to change colors and certain parts of characters, will this be possible and how does my designer need to present the graphics to the programmer so that the programmer can program this himself?!

Please let me know the answers to these questions guys, I really need your help right now!

BTW, you can see part of animation that will be in the game here to give you an idea of what I'm talking about: http://www.sendspace.com/file/t4yn5a

Looking forward to your replies guys and thank you in advance for your help!
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
This is something you'll have to work out with your programmer once you have one. Looking at that example animation, I can think of many different equally valid ways to implement it. There's no clear "right way to do it" that's better than any other.

My first inclination would be to break the boy down into several parts which can move independently (body, eyes, eyebrows, mouth, hand, etc.) and have PNGs for each animated state of those, which would be assembled into the animation at runtime based on some metadata that specifies how they move together. This is by no means a definitive answer about how it would be done, just to give you an example of one possibility.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.11
Post: #3
Thanks for your reply!

So I take it we are on the right track with the designer in terms of presenting programmers with frame-by-frame PNG's for each and every animation and than they will be able to connect everything themselves with a method that will work best for them, correct?!

Also, will they be able to change the color of the boy's hat from red to green for instance by the way of programming or will my designer have to present all hats with different color himself? How does this work?

Stan
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2011.06
Post: #4
Hi Stan

You can implement your animations as a series of PNG files, but there are a couple of issues that you might not be aware of. First, a PNG animation will typically max out at about 11 FPS on an iPhone, it is an embedded device without a lot of CPU to spare. You will want to avoid the UIImageView animation frames API completely as it will suck up all your system memory and crash you phone.

For your specific situation, you will likely want to do with the most simple implementation. That is using multiple animations for different body parts. Then, show them in overlapping views or CALayer objects that sit on top of each other. That way, things like an eye blink loop can be separate from lips moving, and so on. Use layers with alpha channels, so that only the parts you need are visible in each layer and let the system composite the layers together at runtime.

You might also want to consider my AVAnimator library, it is a highly optimized implementation of APNG and Quicktime Animation support for iOS.

http://www.modejong.com/AVAnimator/

This library supports inter frame compression (that saves a lot of space vs a series of PNG images because only frame deltas are stored) and it also supports data compression with 7zip.
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #5
(Jun 8, 2011 02:24 PM)mdejong1024 Wrote:  ...First, a PNG animation will typically max out at about 11 FPS on an iPhone...
I doubt that's the case even with UIKit but I guarantee you can beat 11 FPS using OpenGL.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2011.06
Post: #6
(Jun 8, 2011 03:44 PM)Frank C. Wrote:  
(Jun 8, 2011 02:24 PM)mdejong1024 Wrote:  ...First, a PNG animation will typically max out at about 11 FPS on an iPhone...
I doubt that's the case even with UIKit but I guarantee you can beat 11 FPS using OpenGL.

It actually does not matter if you are using UIKit or OpenGL to do the blit operation (sending the decoded image data to the graphics card). The bottleneck is in the image decode operation, while generating the framebufer that will be uploaded to the graphics card. Using a series of PNG images and decoding the image data when it is time to change frames works up to the point where you need better than 11 FPS. The iPhone just do not have that fast a CPU, so there is only so much CPU intensive stuff you can do before hitting the limits. Even with UIKit, it is possible to blit a full screen buffer at 30 FPS. But, the iPhone can't decode the image data fast enough to use a series of PNG images like that.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
so don't decode the PNGs each frame. Why would you even consider it?
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2011.10
Post: #8
Stansoft, can you please describe the solutions you arrived at? I'm currently dealing with similar concerns over my own game.

Thanks
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  animation on iphone ? imaumac 7 7,175 May 2, 2013 09:57 PM
Last Post: mdejong1024
  iPhone CALayer constraint question sritchie09 0 3,228 Jul 8, 2009 05:32 PM
Last Post: sritchie09
  Cocoa Animation Question DesertPenguin 10 7,093 Feb 12, 2008 02:58 PM
Last Post: OneSadCookie