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

Manipulating physical properties

Box2D allows the user to set physical properties on bodies to create a wide array of effects. In this example, we see a block of ice pushing a box down a slope. We also see a number of bouncing balls.

Manipulating physical properties

Getting ready

Please refer to the project RecipeCollection02 for full working code of this recipe.

How to do it...

Execute the following code:

@implementation Ch4_PhysicalProperties -(CCLayer*) runRecipe { [super runRecipe]; [message setString:@"Friction and restitution"]; //Variable initialization movableObjects = [[[NSMutableArray alloc] init] autorelease]; objectGrabbed = NO; //Create level boundaries [self addLevelBoundaries]; ...

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