Cocos2d iphone 更改棱柱点发动机方向

Cocos2d iphone 更改棱柱点发动机方向,cocos2d-iphone,box2d,Cocos2d Iphone,Box2d,创建运动类型后,是否可以修改发动机的方向 这是关节的定义: //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

创建运动类型后,是否可以修改发动机的方向

这是关节的定义:

//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);
在CCTouches内部,我尝试更改力值,但不起作用:

    _horPrismaticJoint->SetMaxMotorForce(-200.0f);

cocos发行版是cocos2d-iphone-1.0.1

是的,您只需要更改速度(而不是最大力):


“最大力”描述了关节电机的强度,因此它不应为负值。

我测试了它,并根据需要工作。谢谢但是,MaxSpeedForce的负值有什么意义吗?不,它没有真正意义。对于棱柱关节,Box2D似乎将负值视为正值。
joint->SetMotorSpeed( -3.0f );