Closed tantzygames closed 3 years ago
The important part of that example is where the controller is re-activated when the floating action button is pressed:
onPressed: () => _isPlaying ? null : _controller.isActive = true,
Make sure you're setting _controller.isActive to true or playback will not resume.
If that's still not working, could you post your code? There's also a working example provided in this repo: https://github.com/rive-app/rive-flutter/blob/master/example/lib/play_one_shot_animation.dart
Oops sorry, my bad. I extended OneShotAnimation to include speed control using your example for SimpleAnimation which sets it to inactive if !instance.keepGoing:
@override
void apply(rive.RuntimeArtboard artboard, double elapsedSeconds) {
if (instance == null || !instance.keepGoing) {
isActive = false;
return;
}
instance
..animation.apply(instance.time, coreContext: artboard, mix: mix)
..advance(elapsedSeconds * speed);
}
Removing the check for keepGoing fixes it
Following this tutorial: https://help.rive.app/runtimes/playback#repeatedly-playing-a-one-shot-animation
Except the animation never repeats.
It seems when the animation completes _didLoop is set to true which prevents it from ever playing again:
It's only able to play again after I set _didLoop to false.