Question about animation in an iPhone game

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!

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.

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?

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.

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