我对Box2D还不熟悉,我有两具尸体。一个是静态的,另一个是动态的。我想让我的身体向下,然后回来,沿着同一条线撞到另一个身体。经过初步研究,我想用棱柱关节。我查看了一些示例,并在onloadscene()中编写了一段代码。但什么也没动。代码如下:

@Override
public Scene onLoadScene()
{
 .....
    PrismaticJointDef prismaticJointDef = new PrismaticJointDef();
    prismaticJointDef.initialize(bdy_holder, bdy_spring, bdy_holder.getWorldCenter(), new Vector2(1.0f, 0.0f));
    prismaticJointDef.lowerTranslation = -5.0f;
    prismaticJointDef.upperTranslation = 2.5f;
    prismaticJointDef.enableLimit = true;
    prismaticJointDef.maxMotorForce = 200.0f;
    prismaticJointDef.motorSpeed = 10.0f;
    prismaticJointDef.enableMotor = true;
    prismaticJointDef.collideConnected = true;

    prismatic_Joint = (PrismaticJoint)this.mPhysicsWorld.createJoint(prismaticJointDef);
}

现在我认为当我运行应用程序时,实体应该在移动,但它们不会移动。我是新来的,不知道具体的问题是什么。请引导我使用这个问题,解决方案和适当的例子。谢谢。

最佳答案

尝试

prismaticJointDef.collideConnected = false;

10-08 14:20