How make a basic rope?

Hi! i feel very desperate…
I want make a rope, for a bit project…but i alway failing…
I look all topics of here…and look very documentation… but can’t make a rope…
I try copy code of chain.h but is very difficult for me…
Plz only i want a basic project with a rope… :frowning:
help!
I used b2body, verlet etc buti dont known how work it :S

Easiest way to make a simple rope using box2d…

Create a body as a thin rectangle.
Create a 2nd body as a thin rectangle
Create a revolute joint joining the top of rectangle 2 with the bottom of rectangle 1

repeat for as many rectangles as you need for your length of rope

if the rectangles are small enough you should get something rope-like.

You can attach a rectangular sprite to each b2Body and end up with something at least rope-like

You can use a rope joint as well, depending on your requirements

If you look at the box2d tests in the cocos2d-x test project you will see an example of this in RopeJoint.h

Thanks! now i can look a rope… but i have other problems…
1r: I create 2 b2Body, later i create a rope and union both objects.

cocos2d::CCSprite* sprite = cocos2d::CCSprite::create("star.png"); sprite->setTag(valor);//definimos ke valor queremos como nodo! valor++; this->addChild(sprite);
// Defines the body of your candy
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position = b2Vec2(pt.x,pt.y);
bodyDef.userData = sprite;
bodyDef.linearDamping = 0.3f;// mas alta mas lenta...
b2Body* body = world->CreateBody(&bodyDef);

b2CircleShape circle;
circle.m_radius = WORLD_TO_SCREEN(0.6);
b2FixtureDef fixtureDef;
fixtureDef.shape = &circle;
fixtureDef.density = 30.0f;
fixtureDef.filter.categoryBits = 0x01;
fixtureDef.filter.maskBits = 0x01;

body->CreateFixture(&fixtureDef);
later create a rope with this objects. void HelloWorld::createRopeD(b2Body* bodyA,b2Vec2 anchorA,b2Body* bodyB,b2Vec2 anchorB,float32 sag) { b2RopeJointDef jd; jd.bodyA = bodyA; jd.bodyB = bodyB; jd.localAnchorA = anchorA; jd.localAnchorB = anchorB;
// Max length of joint = current distance between bodies * sag
float32 ropeLength = (bodyA->GetWorldPoint(anchorA) - bodyB->GetWorldPoint(anchorB)).Length()*sag;
//CCLOG("BODYA LEGD= %f", anchorA);
//CCLOG("BODY B LEGD= %f", bodyB->GetWorldPoint(anchorB).Length());
//CCLOG("SAG= %f   LEGH= %f", sag,ropeLength);
jd.maxLength = 50;
//jd.maxLength = ropeLength;

//Create joints..
b2RopeJoint* ropeJoint = (b2RopeJoint*)world->CreateJoint(&jd);
//b2Joint* ropeJoint = (b2Joint*)world->CreateJoint(&jd);
VRope* newRope = new VRope(ropeJoint,ropeSpriteSheet);

ropes->push_back(newRope);

}
///
Now i have 3 problem…
1, only can create a ropeJoint…i don’t known who change this…

2n: with the rope create… i can’t manipule object, before rope i cna touch and move objects with rat, later i CAN’T!.

3: Mi 2 object have attraction, and go of the same point… and i can’t stop it…

Solution? plz :S and ty :smiley: