PhysicsMouseJoint problem in andengine + Box2d

Posted by Nikhil Lamba on Game Development See other posts from Game Development or by Nikhil Lamba
Published on 2012-06-20T06:01:35Z Indexed on 2012/06/20 9:25 UTC
Read the original article Hit count: 438

Filed under:
|
|

What we can remove from this code i.e from PhysicsMouseJointExample to remove the functionality of drag and drog of sprite but i need all functionality except this only user move the sprite with some force and velocity of fling but user can't move the ball as like drag and drop like moving a finger on screen and sprite move with finger plz plz help me

I am Using Below method for Mouse Joint

CODE :

      public MouseJoint createMouseJoint(final IShape pFace, final float     pTouchAreaLocalX, final float pTouchAreaLocalY) 
{
    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);
    this.groundBody.setTransform(localPoint, 0);
    mouseJointDef.bodyA = this.groundBody;
    mouseJointDef.bodyB = body;
    mouseJointDef.dampingRatio = 0.95f;
    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);
}

© Game Development or respective owner

Related posts about box2d

Related posts about 2d-physics