In this chapter, you learned the uniqueness of physical behaviors in video games and how to make the best use of the physics engine included in Cocos2d, that is, Chipmunk.
We configured the Chipmunk space thanks to the CCPhysicsNode
class and its properties such as gravity. Then we added some bodies and convex shapes and saw the attributes we can modify on the CCPhysicsBody
and CCPhysicsShape
classes to get the desired result.
You also learned that we can provide physics behavior to objects beyond bodies and shapes by creating a sprite and linking a physics body to it. Then you learned to create concave shapes and configure their physics properties thanks to physics editors such as PhysicsEditor and how to load this shape in our Xcode project.
To define the interaction between objects in the same space, you saw how to detect and manage collisions with the different approaches Chipmunk offers. Thanks to the knowledge acquired in the chapter, we implemented a kind of snooker game in which...