如何在适用于android的Box2d中使用棱柱关节

如何在适用于android的Box2d中使用棱柱关节,android,box2d,andengine,Android,Box2d,Andengine,我是Box2d新手,我有两具尸体。一个是静态的,另一个是动态的。我希望我的动态身体向下,然后回来,沿着同一条线撞击另一个身体。经过初步研究后,我想使用棱柱关节。我研究了一些示例,并在onLoadScene()中编写了一段代码。但一切都没有改变。代码如下: @Override public Scene onLoadScene() { ..... PrismaticJointDef prismaticJointDef = new PrismaticJointDef(); prism

我是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;