I am new in box2d and also in andengine. I want to create a spring body. I have used to joints revolute joint and mouse joint. Actually my requirement is that if I release the body of moving the object. It should give me an effect of spring which moves in limits. For example if the board is jointed with a pole and i drag it down ward and release it then it gives a dumping effect and then stay on its actual position. I have made two bodies and I can drag it but it does not stop after releasing and also does not stay also it actual position. Please guide me and try to help me. Thanks you so much...
Revolute Joint...
final RevoluteJointDef revoluteJointDef = new RevoluteJointDef();
revoluteJointDef.initialize(anchorBody, movingBody, new Vector2(1, movingBody.getPosition().y));
revoluteJointDef.collideConnected = false;
revoluteJointDef.enableMotor = false;
revoluteJointDef.motorSpeed = 0;
revoluteJointDef.maxMotorTorque = 0;
revoluteJointDef.enableLimit = true;
revoluteJointDef.lowerAngle = MathUtils.degToRad(-30);
revoluteJointDef.upperAngle = MathUtils.degToRad(30);
mPhysicsWorld.createJoint(revoluteJointDef);
Mouse Joint...
final Body body = (Body) pFace.getUserData();
final MouseJointDef mouseJointDef = new MouseJointDef();
final Vector2 localPoint = Vector2Pool.obtain((pTouchAreaLocalX - pFace.getWidth() * 0.5f) / physicsConstants.PIXEL_TO_METER_RATIO_DEFAULT, (pTouchAreaLocalY - pFace.getHeight() * 0.5f) / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT);
mGroundBody.setTransform(localPoint, 0);
mouseJointDef.bodyA = mGroundBody;
mouseJointDef.bodyB = body;
mouseJointDef.dampingRatio = 1.0f;
mouseJointDef.frequencyHz = 30;
mouseJointDef.maxForce = 200.0f * body.getMass();
mouseJointDef.collideConnected = true;
mouseJointDef.target.set(body.getWorldPoint(localPoint));
Vector2Pool.recycle(localPoint);
return (MouseJoint) mPhysicsWorld.createJoint(mouseJointDef);
