'Why SpriteAnimation.onComplete do not trigger after restarting the game in Flutter Flame?
In a game with Flame engine, Player has a dead animation which is falling slowly when its dead, I wait to play dead animation to pause the game engine and display game over overlay, it works correctly for the first time game starts, but after game over when I restart the game, onComplete callback doesn't triggers at all. Why?
deadSpriteAnimation.onComplete = () {
GameModel.instance.pauseGameEngine();
gameRef.overlays.add(GameOverOverlay.id);
};
Solution 1:[1]
You are probably using the same SpriteAnimation object in the second run, which has already finished. Either you have to re-create the SpriteAnimation or reset it before you add it again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | spydon |
