playOnce method

Future playOnce(
  1. FutureOr<SpriteAnimation> animation, {
  2. VoidCallback? onFinish,
  3. bool runToTheEnd = false,
  4. bool flipX = false,
  5. bool flipY = false,
})

Method used to play animation once time

Implementation

Future playOnce(
  FutureOr<SpriteAnimation> animation, {
  VoidCallback? onFinish,
  bool runToTheEnd = false,
  bool flipX = false,
  bool flipY = false,
}) async {
  runToTheEndFastAnimation = runToTheEnd;
  final anim = AnimatedObjectOnce(
    position: position,
    size: size,
    animation: animation,
    onFinish: () {
      onFinish?.call();
      _fastAnimation = null;
    },
  );
  anim.isFlipVertical = flipY;
  anim.isFlipHorizontal = flipX;
  if (gameRef != null) {
    anim.gameRef = gameRef!;
  }
  await anim.onLoad();
  _fastAnimation = anim;
}