O'Reilly logo

Cocos2d for iPhone 1 Game Development Cookbook by Nathan Burba

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

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; ...

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