Book Image

Mastering Cocos2d Game Development

By : Alex Ogorek
Book Image

Mastering Cocos2d Game Development

By: Alex Ogorek

Overview of this book

Table of Contents (15 chapters)
Mastering Cocos2d Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Learn how Chipmunk works


As previously mentioned, Chipmunk is the physics engine that's integrated with Cocos2d, and is the main physics engine from version 3.0 onwards. The good news for both newcomers and fans of Box2D alike is that Chipmunk is very simple to use. Let's get down to how Chipmunk basically works.

Overall structure of Chipmunk

Chipmunk is a physics engine in Cocos2d that simulates real-world physics, that is, making use of gravity, collisions, objects bouncing off each other, and so on.

Chipmunk uses a "bodies within a world" way of doing things. This means that, as shown in the following diagram, there's a physics simulation happening (called a world), and anything with physics applicable to it is a body. You just create a world that will simulate physics on the bodies within, and off you go. Each world you create will have its own gravity attached to it.

This is a simple representation of bodies within a world. Note that the entire green rectangle is the world, and the individual...