문제

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