playSpriteAnimationOnce method

Future<void> playSpriteAnimationOnce(
  1. FutureOr<SpriteAnimation> animation, {
  2. Vector2? size,
  3. Vector2? offset,
  4. VoidCallback? onFinish,
  5. VoidCallback? onStart,
  6. bool loop = false,
})

Method used to play animation once time

Implementation

Future<void> playSpriteAnimationOnce(
  FutureOr<SpriteAnimation> animation, {
  Vector2? size,
  Vector2? offset,
  VoidCallback? onFinish,
  VoidCallback? onStart,
  bool loop = false,
}) async {
  final completer = Completer();
  _fastAnimation = SpriteAnimationRender(
    position: offset,
    size: size ?? this.size,
    animation: await animation,
    loop: loop,
    onFinish: () {
      _fastAnimation = null;
      onFinish?.call();
      completer.complete();
    },
    onStart: onStart,
  );
  return completer.future;
}