Hello everyone,
It's my first time using the Box2D physics engine for a LibGDX project, and i'm struggling with this one thing: I'm trying to swipe a ball (wich is a b2D body) using the fling method from the GestureListener. So, when there's a fling, i apply a force to the ball, like this:
( Excuse my paint skills, hope its understandable... )
https://i.gyazo.com/94e6c3ad347eff9688d707e6bb7f4ce2.png
Here's my fling method so far:
@Override
public boolean fling(float velocityX, float velocityY, int button) {
ball.getBody().setActive(true);
System.out.println("Mouse pos is " + mouse.toString());
ball.getBody().applyForce(new Vector2(mouse.x - ball.getBody().getPosition().x, 30), ball.getBody().getWorldCenter(), true);
return super.fling(velocityX, velocityY, button);
}
So, how exaclty could i achive something like in that picture above? Any tips would be greatly appreciated!