Reputation: 5227
I am new to Box2d and have a situation where I have two bodies. One is static and the other is dynamic. I want my dynamic body to go down wards and come back and hit the other body along same line. I thought to use prismatic joint after some initial study. I have looked into some example and written a piece of code in onLoadScene(). But nothing is moving. Here is the code:
@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);
}
Now I think the bodies should be moving when I run the application, but they are not movng. I am totally new and can't figure out the exact problem. Kindly guide me to the problem, solution and proper example of using this. Thanks.
Upvotes: 2
Views: 1515