Simulating and rendering a rope

A recent addition to the Box2D library is the b2RopeJoint . In this recipe, we will see how to implement this physically and visually.

Simulating and rendering a rope

Getting ready

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

How to do it...

Execute the following code:

#import "VRope.h" @implementation Ch4_Rope -(CCLayer*) runRecipe { [super runRecipe]; [message setString:@"Press B to fire a rope."]; //Initialization onRope = NO; ropeUseTimer = 0; //Move gunman to left gunman.body->SetTransform(b2Vec2(2,10), gunman.body->GetAngle()); //Create ...

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.