Search code examples
flutterflame

Flame - onComplete and reset() removed from SpriteAnimation


I used to be able to call

spriteAnimation.reset()

or

spriteAnimation.onComplete = (){}

But once I upgrade to flame 1.8.0, they got removed.

What are the new solutions for the above behaviors?


Solution

  • They have been moved to the SpriteAnimationTicker so that an animation class can be used by multiple components at the same time.

    So if you have a a SpriteAnimationComponent for example, then you have the reset method and the onComplete callback on the ticker and they are used like this:

    spriteComponent.animationTicker.reset();
    spriteComponent.animationTicker.onComplete = (){};