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

Using Chipmunk for just collision detection


Tip

Here is an important note: if you're going to just detect one of the following, you do not need to use a physics engine for your collision detection, but rather the listed method:

  • For rectangles intersecting rectangles, use CGRectIntersectsRect

  • For points inside rectangles, use CGRectContainsPoint

  • For radius/distance intersection, use ccpDistance

If you're going to be detecting collisions with non-rectangular and noncircular objects, feel free to read on.

Sometimes, all you're doing is sending objects across the screen, or rotating them with your custom actions, and you just want to know when two objects collide, but don't want the bouncing, pushing, and colliding that comes with the entire physics engine. Luckily, we can do that in Chipmunk.

Turning the physics body into a sensor

Sensors, with respect to Chipmunk, are basically bodies that can detect collisions, but pass right through other bodies. These are helpful when you have areas or sections...