2

Is there any way that a can stop an action where it is before it is completed in libGDX Scene2D. I have an actor that is in the middle of a moveTo action but when i set a boolean gameOver to true I want the actor to stop where it is. How would I do that? It seems simple but I cant figure it out.

4

1 回答 1

11

您可以通过以下方式停止Actions:

  1. actor.removeAction(Action)用or删除它们actor.clearActions()
  2. 您可以覆盖该actor.act(delta)方法,如果gameOver已设置,则不要更新Actor(不要调用super.act()
  3. renderdon't call actfor the stage, ifgameOver中设置

所以基本上s 在 的方法中Action得到更新。如果您设置为您可以简单地停止更新:actActorgameOvertrueStage

在渲染中:

if (!gameOver) {
    stage.act();
}
stage.draw();
于 2014-04-15T06:01:23.623 回答