playOnceOther method

Future<void> playOnceOther(
  1. dynamic key, {
  2. VoidCallback? onFinish,
  3. VoidCallback? onStart,
  4. bool runToTheEnd = false,
  5. bool flipX = false,
  6. bool flipY = false,
  7. bool useCompFlip = false,
  8. Vector2? size,
  9. 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;
}