playOnce method
Future<void>
playOnce(
- FutureOr<
SpriteAnimation> animation, { - VoidCallback? onFinish,
- VoidCallback? onStart,
- bool runToTheEnd = false,
- bool flipX = false,
- bool flipY = false,
- bool useCompFlip = false,
- Vector2? size,
- Vector2? offset,
Method used to play animation once time
Implementation
Future<void> playOnce(
FutureOr<SpriteAnimation> animation, {
VoidCallback? onFinish,
VoidCallback? onStart,
bool runToTheEnd = false,
bool flipX = false,
bool flipY = false,
bool useCompFlip = false,
Vector2? size,
Vector2? offset,
}) async {
_fastAnimationUseCompFlip = useCompFlip;
final completer = Completer();
_fastAnimation?.onFinish?.call();
runToTheEndFastAnimation = runToTheEnd;
if (useCompFlip) {
isFlipHorizontallyFastAnimation = isFlipHorizontally;
isFlipVerticallyFastAnimation = isFlipVertically;
} else {
isFlipHorizontallyFastAnimation = flipX;
isFlipVerticallyFastAnimation = flipY;
}
_fastAnimation = SpriteAnimationRender(
size: size ?? this.size,
position: offset,
animation: await animation,
loop: false,
onFinish: () {
onFinish?.call();
_fastAnimation = null;
completer.complete();
},
);
onStart?.call();
return completer.future;
}