0

ジョイントを作成した後、エンジンの方向を変更することはできますか?

これはジョイントの定義です:

//Define a prismatic joint
b2PrismaticJointDef jointDef;

b2Vec2 axis = b2Vec2(1.0f, 0.0f);
axis.Normalize(); //Important

jointDef.Initialize(staticBody, body, b2Vec2(0.0f, 0.0f),axis);

jointDef.localAnchorA = b2Vec2(0.0f,0.0f);
jointDef.localAnchorB = body->GetLocalCenter();
jointDef.motorSpeed = 3.0f;
jointDef.maxMotorForce = +200*body->GetMass();

jointDef.enableMotor = true;

jointDef.lowerTranslation = -2.0f;
jointDef.upperTranslation = 3.0f;
jointDef.enableLimit = true;

_horPrismaticJoint = (b2PrismaticJoint*) world->CreateJoint(&jointDef);

CCTouchesBeganの内部で、力の値を変更しようとしましたが、機能していません。

    _horPrismaticJoint->SetMaxMotorForce(-200.0f);

cocosの分布はcocos2d-iphone-1.0.1です。

4

1 に答える 1

1

はい、速度を変更する必要があります(最大力ではありません):

joint->SetMotorSpeed( -3.0f );

最大力は、ジョイントモーターの強度を表すため、負の値にしないでください。

于 2012-07-04T09:02:05.153 に答える