Я хочу использовать moveToAction и переместить актера. Но это не движется, если я использую moveToAction. При изменении x, y в методе draw это работает, но не с помощью movetoaction
public class Aks extends Actor {
private State state;
private MainGame game;
private TextureAtlas movingAtlas;
private Animation movingAnimation;
private float elapsedTime = 0f;
public Aks(MainGame game) {
this.game = game;
movingAtlas = new TextureAtlas(Gdx.files.internal("atlas/myaltas/atlas.atlas"));
movingAnimation = new Animation(1f/15f, movingAtlas.getRegions());
TextureRegion texture = (TextureRegion) movingAnimation.getKeyFrame(elapsedTime, true);
setBounds(getX(),getY(),texture.getRegionWidth(),texture.getRegionHeight());
MoveToAction moveAction = new MoveToAction();
moveAction.setPosition(300f, 300f);
moveAction.setDuration(10f);
this.addAction(moveAction);
addListener(new ActorGestureListener(){
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
Gdx.app.log("Tag", "Actor touched x = " );
super.tap(event, x, y, count, button);
}
});
}
@Override
public void draw(Batch batch, float alpha){
drawFlying(batch);
}
void drawFlying(Batch batch){
TextureRegion texture = (TextureRegion) movingAnimation.getKeyFrame(elapsedTime, true);
setBounds(getX(),getY(),texture.getRegionWidth(),texture.getRegionHeight());
Gdx.app.log("Tag", "x =" + getX() + " y =" + getY() );
batch.draw(texture, getX(),getY(),50,50);
}
@Override
public void act(float delta){
elapsedTime = elapsedTime+delta;
}
}