I have tried a lot to find a solution for moving a dynamic body smoothly on the screen. Mouse Joint doesn't work for me, it has that rubber band effect that isn't useful for smooth movements. I have also tried to apply linear velocity to make the ball move, but couldn't do it so. What are the options to get a simple touch movement on bodies? For example, similar to Glow Hockey?
The answer need not to be specific to AndEngine. Cocos2d would work for me as well.
I've registered Touch listener, and try to move the body on 'Move' Action using:
public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final ITouchArea pTouchArea, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
switch(pSceneTouchEvent.getAction()){
case TouchEvent.ACTION_DOWN:
break;
case TouchEvent.ACTION_MOVE:
strikerBody.setLinearVelocity((pSceneTouchEvent.getX()-strikerBody.getPosition().x * PIXEL_TO_METER_RATIO_DEFAULT),(pSceneTouchEvent.getY()-strikerBody.getPosition().y * PIXEL_TO_METER_RATIO_DEFAULT));
break;
case TouchEvent.ACTION_UP:
break;
default:
break;
}}
The body does move and in the right direction, but if finger movement is a little faster it runs away from the finger, as magnitude of the velocity increases.