2
\$\begingroup\$

Why doesn't this work and how do I fix it/create a different, working loop for this SequenceAction?

public void setLoopingFade(float time)
{
    fadeLoop = Actions.sequence(Actions.fadeOut(time), Actions.fadeIn(time), Actions.run(new Runnable()
        {
            @Override
            public void run()
            {
                fadeLoop.restart();
            }
        }));

    this.addAction(fadeLoop);
}

fadeLoop is a SequenceAction. I'm adding the SequenceAction to an Actor.

Clarification
Ok, so what I want to do is fade my actor in and out repeatedly. I figured the best way to do this was to create a SequenceAction that I would loop. The looping is what the Runnable is for. However, this method does not work. The fading out and back in happens once and then nothing. Even though the action is still owned by the Actor. I have also tried calling fadeLoop.reset(), however, that does not work either and actually makes the issue worse, because, when calling restart() I can still restart the SequenceAction manually from a different class, but when calling reset() the action loses all functionality.
I have tried adding a boolean functionality that would alert the external class to restart the action, but because the action ends after changing the boolean, it is removed from the actor and despite re-adding the action, it still does not work.

\$\endgroup\$
3
\$\begingroup\$

Why not using Actions.forever(Action repeatedAction) ?

Example :

fadeLoop = Actions.forever(Actions.sequence(Actions.fadeOut(time), Actions.fadeIn(time)));
this.addAction(fadeloop)
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.