I want to show a fancy entering animation, like enemy jumps out of a black hole, comprised of multiple images in a png file. Once that's done, the enemy will show the idle image sprite.
I thought about SpriteAnimationGroupComponent to have something like
enum PlayerState { entering, idle, disappearing }
but the problem is I can not tell when the entering animation is finished so that I can transfer it to idle state.
Also thought about Effect but it doesn't work with images.
Is there an ideal approach for it? Many thanks.
You can add an onComplete
callback to the entering
animation and set the state of the player to idle
.
Something like this:
final yourComponent = SpriteAnimationGroupComponent(...);
yourComponent.animations[PlayerState.entering].onComplete =
() => yourComponent.current = PlayerState.idle;