O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Collision detection

The Chipmunk physics engine also includes a collision detection mechanism that can be used to check collisions between physics bodies. So, it is a prerequisite that both the objects need to have physics bodies attached for this to work.

Here, we will check the collision between the bottom of the basket and the ornament and gift. We won't include the candy stick for the example, but the process is the same.

We will also take a look at the collision between the gift, ornament, and edge loop.

If either the ornament or gift collides with either the edge loop or the bottom of the basket, we will delete the object colliding with them.

Getting started

To get the collision to work, we have to set MainScene as the delegate class. To use ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required