flame-engine / flame

A Flutter based game engine.
https://flame-engine.org
MIT License
8.98k stars 879 forks source link

Add support for on complete animation for Flame lottie #3166

Closed CristovoXDGM closed 1 month ago

CristovoXDGM commented 1 month ago

Problem to solve

Currently there is no way to check if a LottieComponent has finished their animation to trigger something.

Proposal

Would be good to have that, so we can be able to chain things related to animations. One use for that is to use more lottie animations for games since their are lightweight.

More information

I know how to do that in flutter using a completer and a listener for the animation, but it seens to vsync not work for flame components

Other

CristovoXDGM commented 1 month ago

@spydon Man, can you help with that ? or is better to use rive instead to have the state machine ?

spydon commented 1 month ago

@spydon Man, can you help with that ? or is better to use rive instead to have the state machine ?

I would say in general I would choose Rive over Lottie, but if you want to do a PR with a callback or completer you can have a look at how it is done for the SpriteAnimationComponent for example.

spydon commented 1 month ago

I just had a look, and you can already do this. Since you can pass in an EffectController you can add an onMax callback to that one which will be called when the animation is done. :)