playSpriteAnimationOnce method

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

Method used to play animation once time

Implementation

Future playSpriteAnimationOnce(
  FutureOr<SpriteAnimation> animation, {
  Vector2? size,
  Vector2? offset,
  VoidCallback? onFinish,
  VoidCallback? onStart,
}) async {
  _fastAnimOffset = offset ?? Vector2.zero();
  _fastAnimation?.onRemove();
  _fastAnimation = AnimatedObjectOnce(
    position: position + _fastAnimOffset,
    size: size ?? this.size,
    animation: animation,
    onStart: onStart,
    onFinish: () {
      onFinish?.call();
      _fastAnimation?.onRemove();
      _fastAnimation = null;
    },
  )..gameRef = gameRef;
  await _fastAnimation?.onLoad();
}