Java 使演员动作移动到不停点
我有一个代码,我把一个演员从a点移动到B点,我不想让它停在B点,但要一直朝着同一个方向前进,我不知道怎么做。 我还希望它以固定的速度移动,无论点之间的距离有多大,有人能帮忙吗 行动是:Java 使演员动作移动到不停点,java,android,libgdx,actor,Java,Android,Libgdx,Actor,我有一个代码,我把一个演员从a点移动到B点,我不想让它停在B点,但要一直朝着同一个方向前进,我不知道怎么做。 我还希望它以固定的速度移动,无论点之间的距离有多大,有人能帮忙吗 行动是: Gdx.input.setInputProcessor(new InputAdapter() { public boolean touchUp(int screenX, int screenY, int pointer, int button) { touchposx
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
touchposx = screenX;
touchposy = screenY;
MoveToAction action = new MoveToAction();
action.setPosition(touchposx+300, screenHeight-touchposy+300);
action.setDuration(5f);
bullet.addAction(action);
return true;
}
});
}
您可以通过组合使用moveBy(用于固定速度)、排序操作和移除操作来实现这一点
但在我看来,行动是一个太复杂的方法来解决这个问题。动作主要是为UI动画设计的。相反,我会覆盖bullet的act()方法,使用setPosition并在演员离开屏幕时将其从舞台上移除。您希望它移动到无穷大或多远?移动直到它离开屏幕