Search code examples
javaandroidopengl-eslibgdxscene2d

How is it possible to pause an action of an actor in LibGDX?


I added the following action to my actor:

this.addAction(sequence(delay(0.5f), alpha(1, 2), delay(2), alpha(0, 2)));

Is there an easy way to pause this animation and then continue it when a button is clicked?


Solution

  • If your actor is only running action, I suggest to stop calling the act() method of the actor. Extend Actor to set a switch if needed.

    public void act(){
      if(mUpdateAnimation){
         this.act(delta)
      }
    }