Game Development Reference
Physics engines are what drive popular iOS games like Angry Birds, Stick Golf, Jelly
Car, and Stair Dismount. They allow you to create a world that feels dynamic and life-
Cocos2d is distributed with two physics engines: Box2D and Chipmunk. Both are de-
signed to work only in two dimensions, so they're a perfect fit for cocos2d.
In this chapter, you'll learn the basics of both of these physics engines, and along the
way you'll probably come to appreciate one more than the other. I'll briefly explain the
differences between them, but for the most part it's a choice based on personal preferen-
If you've never worked with a physics engine before, don't worry—I'll also give you a
quick introduction to their basic concepts and key elements.
Basic Concepts of Physics Engines
You can think of a physics engine as an animation system for game objects. Of course,
it's up to the game developer to connect and synchronize game objects like sprites with
the physics objects, called rigid bodies . They're called that because physics engines an-
imate them as if they were stiff, nondeformable objects. This simplification allows phys-
ics engines to calculate a large number of bodies.
There are generally two types of bodies: dynamic (moving) and static (immovable) ob-
jects. The differentiation is important because static bodies never move—and should