Question about animation in an iPhone game - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Question about animation in an iPhone game (/thread-8822.html)
Question about animation in an iPhone game - stansoft - Apr 10, 2011 11:06 PM
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!
RE: Question about animation in an iPhone game - ThemsAllTook - Apr 11, 2011 07:58 AM
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.
RE: Question about animation in an iPhone game - stansoft - Apr 11, 2011 02:37 PM
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?
RE: Question about animation in an iPhone game - mdejong1024 - Jun 8, 2011 02:24 PM
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.
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.
RE: Question about animation in an iPhone game - Frank C. - Jun 8, 2011 03:44 PM
(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.
RE: Question about animation in an iPhone game - mdejong1024 - Jun 8, 2011 03:57 PM
(Jun 8, 2011 03:44 PM)Frank C. Wrote:
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.
RE: Question about animation in an iPhone game - OneSadCookie - Jun 8, 2011 04:57 PM
so don't decode the PNGs each frame. Why would you even consider it?
RE: Question about animation in an iPhone game - Neison - Oct 4, 2011 04:55 AM
Stansoft, can you please describe the solutions you arrived at? I'm currently dealing with similar concerns over my own game.