libgdx Moving actors on path with constant speed Simple movement between two locations


For this the best solution is using actions. To add a new action to an actors in Scene2D just call:

Action action = Actions.moveTo(x,y,duration);

Where x and y is the target location and duration is the speed of this movement in seconds(float).

If you want to stop this action(and the actor by it) you can do it by calling:


or you can remove all actions by calling:


This will immediately stop the running of the action(s).

The moveTo action manipulates the x and y property of the actor, so when you draw the actor to the screen always use getX() and getY() to draw textures. Just like in the following example:

public class MovingActor extends Actor {

    private Action runningAction;
    private float speed = 2f;

    public void moveTo(Vector2 location) {
       runningAction = Actions.moveTo(location.x, location.y, speed);

    public void stopAction() {

    public void stopAllActions() {

    public void draw(Batch batch, float parentAlpha){
        batch.draw(someTexture, getX(), getY());