how to use moveTo?

trying to do that but the actor doesn't move

public class MyActions extends ApplicationAdapter { private Stage stage; private Actor actor; @Override public void create () { stage = new Stage(); actor = new Actor(){ { setSize(100, 100); } Sprite actorSprite = new Sprite(new Texture(Gdx.files.internal("badlogic.jpg")), 57, 10, (int)getWidth(), (int)getHeight()); @Override public void draw(Batch batch, float parentAlpha) { actorSprite.draw(batch, parentAlpha); } }; stage.addActor(actor); actor.addAction(Actions.moveTo(500, 500, 1)); } @Override public void render () { Gdx.gl.glClearColor(1, 1, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); actor.act(Gdx.graphics.getDeltaTime()); //stage.act(); stage.draw(); } } 

share a working example

  • And why stage.act (); commented out? - Konstantin
  • @Konstantin, tried differently, and with him, too, does not move - ravend
  • one
    It is clear that does not move. You do not change the position of the sprite anywhere. Override the void positionChanged method like this: actorSprite.setPosition (x, y); - Master Flomaster
  • @MasterFlomaster, earned, thank you so much! - ravend

0