… 생략 : Box2dEx04의 코드와 같음 …
void HelloWorld::setBox2dWorld()
{
// 마우스 조인트 바디를 생성해서 월드에 추가한다.
bDrag = false;
gbody = this->addNewSprite(Vec2(0, 0), Size(0, 0), b2_staticBody, nullptr, 0);
// *****************************************************************************
b2RopeJointDef ropeJointDef;
b2Body* body1 = this->addNewSprite(Vec2(240, 280), Size(40, 40),
b2_dynamicBody, "test", 0);
b2Body* body2 = this->addNewSprite(Vec2(340, 280), Size(40, 40),
b2_dynamicBody, "test", 0);
ropeJointDef.bodyA = body1;
ropeJointDef.bodyB = body2;
ropeJointDef.localAnchorA = b2Vec2(1.0f, 0.0f);
ropeJointDef.localAnchorB = b2Vec2(-1.0f, 0.0f); // -1 ~ 1
ropeJointDef.maxLength = 1.5; // 0.5 2.5 5.5
ropeJointDef.collideConnected = true;
_world->CreateJoint(&ropeJointDef);
}
… 생략 : Box2dEx04의 코드와 같음 …