質問

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.

役に立ちましたか?

解決

You can stop Actions by:

  1. removing them with actor.removeAction(Action) or actor.clearActions()
  2. you can override the actor.act(delta) method, and if gameOver is set don't update the Actor (don't call super.act())
  3. In the render don't call act for the stage, if gameOver is set

So basicly the Actions get updated in the act method of Actor. If your gameOver is set to true you can simply stop the Stage from updating:

In Render:

if (!gameOver) {
    stage.act();
}
stage.draw();
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top