Creating collision response routines

To make efficient and organized use of Box2D, we must create a few wrapper classes to encapsulate specific functionality. In this recipe, we will use these classes to add collision response routines to our simple falling block demo from the previous recipe.

Creating collision response routines

Getting ready

Please refer to the project RecipeCollection02 for full working code of this recipe. Also, note that some code has been omitted for brevity.

How to do it...

Execute the following code:

/* GameObject.h */ @interface GameObject : CCNode { @public GameArea2D *gameArea; b2Body *body; b2BodyDef *bodyDef; b2FixtureDef *fixtureDef; b2PolygonShape *polygonShape; ...

Get Cocos2d for iPhone 1 Game Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.