[SOLVED][libGDX] Action.restart() works, SequenceAction.restart() doesn't work

Hello,

I have a class in which you call setAction(Action action) method to set the action you want to be performed when calling play() method. The problem is when I put Actions.sequence(Actions.moveBy(50f, 0f, .2f), Actions.moveBy(-50f, 0f, .2f)), the action does not restart, but if I only put Actions.moveBy(50f, 0f, .2f), the action restarts. I tried restarting each action manually by calling getActions() method on SequenceAction, but it does not work either.

This is the code that makes Actor play specified action:


  public void play() {
    action.restart();
    addAction(action);
  }

My mind is blown and if nobody knows how to fix this, I will have to create an array of actions that will manually get sequenced once each ends, but I would like to avoid that.

Thanks in advance!

EDIT #1: I reported this as a bug to the LibGDX issue tracker.
EDIT #2: Crosspost on Libgdx Forums

EDIT #3: Solution as posted on Libgdx Forums by evilentity:
JGO system didn’t allow me to put the following in quotes, so yeah.

You are holding a reference to pooled action. Pooled actions are freed when they complete. This resets them. This make your sequence both an invalid reference and empty. Actions it contained are released back to the pool. If you want the reference for whatever reason, just create it manually.


MoveByAction mb1 = new MoveByAction();
mb1.setAmount(50, 0);
mb1.setDuration(.2f);
MoveByAction mb2 = new MoveByAction();
mb2.setAmount(-50, 0);	
mb2.setDuration(.2f);
action = new SequenceAction(mb1, mb2);