A recent addition to the Box2D library is the b2RopeJoint
. In this recipe, we will see how to implement this physically and visually.
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.
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 buttons [self createButtonWithPosition:ccp(340,75) withUpFrame:@"b_button_up.png" withDownFrame:@"b_button_down.png" withName:@"B"]; [self createButtonWithPosition:ccp(420,75) withUpFrame:@"a_button_up.png" withDownFrame:@"a_button_down.png" withName:@"A"]; //Create ground /* CODE OMITTED */ //Add invisible...