Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

Move body LibGDX Box2D

$
0
0

Hello I have a body and I want to move it. When I press the mouse button my body should move at that position (on the const speed)on the screen. I have override two methods(x1, y1 – point where my body need to go)

    public boolean touchDown(int x1, int y1, int pointer,
            int button) {
        x = x1;
        y = y1;
        move.set(x1 - ball.getPosition().x, y1 - ball.getPosition().y).nor();
        return false;
    }

    @Override
    public boolean touchUp(int screenX, int screenY, int pointer,
            int button) {
        move.set(ball.getPosition().x, ball.getPosition().y);
        return false;
    }

and in my rener method I have write this

ball.applyForceToCenter(move, true);

but my ball don’t move! why? whats wrong? is there are any alternatives how to move mody at specific point on the screen?


Viewing all articles
Browse latest Browse all 434

Trending Articles