playOnceOther method
Future<void>
playOnceOther(
- dynamic key, {
- 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> playOnceOther(
dynamic key, {
VoidCallback? onFinish,
VoidCallback? onStart,
bool runToTheEnd = false,
bool flipX = false,
bool flipY = false,
bool useCompFlip = false,
Vector2? size,
Vector2? offset,
}) async {
if (others.containsKey(key) != true) {
return Future.value();
}
_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: others[key],
loop: false,
onFinish: () {
onFinish?.call();
_fastAnimation = null;
completer.complete();
},
);
onStart?.call();
return completer.future;
}