Open BobaTrek opened 1 year ago
Hi @BobaTrek have you taken a look at OneShotAnimation?
Yes, I did use OneShotAnimation first, but I need to be able to change the speed of the animation as well, so I switched to the SpeedController mechanism. I am still thinking _didloop should be set to false in the LinearAnimationInstance.reset() function, but at least for now there is a workaround by calling .advance(0).
(Switching to SpeedController has presented a different problem, see #317)
I'll take a deeper look into this soon.
Description
The class LinearAnimationInstance sets _didLoop to true after completing a one-shot animation. The class LinearAnimationInstance then returns false for keepGoing because of the following line of code:
bool get keepGoing => animation.loop != Loop.oneShot || !_didLoop;
Consequently, after running the animation once, setting controller.isActive back to true does not re-run the animation. Perhaps this is intentional?
Workaround?
I found the following code will allow you to re-run the animation (scPulse is my SpeedController which uses LinearAnimationInstance:
scPulse.instance.reset();
scPulse.instance.advance(0); // This sets _didloop back to false as a side effect;
scPulse.isActive = true;
Should _didloop be set to false as part of the reset() call (or when isActive gets set false) instead of relying on the side effect of calling advance(0)?