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 回答