views:

288

answers:

4

If you've played Plants vs Zombies, you've seen how fluid and remarkable the character animation is. Can anyone assume how they are doing this? They don't seem to simply be animating bitmaps; the animation is too crisp, even as characters rotate and scale. The artwork looks vector, but I can't imagine that everything is drawn out using Core Graphics. Any ideas?

+2  A: 

My guess: OpenGL. Core Graphics doesn't have the performance on the iPhone to do real-time vector graphics at that level of detail. From a cursory look at the PvZ graphics, I think they're using individual bitmaps for plant and zombie body parts—a peashooter, for instance, probably consists of a base, a couple of leaves attached thereto, a head, and a stem (which gets skewed back and forth as the "head" bobs). In other words, the bitmaps themselves aren't changing; they're just getting moved and rotated in relation to each other, which is something OpenGL is ideally suited to.

Noah Witherspoon
+1  A: 

If you want to do the more intense, smooth graphics that respond dynamically to user input (i.e. a game - like PvZ), OpenGL is the way it's done. It's not the dynamic drawing of the images and graphics that ultimately kills you but the overhead of the event loop when you plop the details into an open-ended runloop (i.e. Core Animation and UIKit programming) in the Objective-C runtime.

heckj
A: 

You could definitely pull this off using CoreGraphics and spritesheets.

Sneakyness
+1  A: 

As others have noted, they probably use OpenGL or a game engine that runs on top of OpenGL.

If you want to achieve something like this, I'd suggest using cocos2d for iPhone. It is built on top of OpenGL, but uses Objective-C and geared towards 2D games. As such, it provides sprite sheet support, a particle system, actions, visual effects and more.

Colin Gislason