Class Animation.ExclusiveRunner

java.lang.Object
ch.hevs.kart.utils.Animation.ExclusiveRunner
Enclosing class:
Animation

public static class Animation.ExclusiveRunner extends Object

The ExclusiveRunner class ensures that only exactly one animation is running at the same time in its context. This means if the runner is instructed to run a new animation and there is still an animation running in his context, the already running animation will be stopped before the new one is started.

  • Constructor Details

    • ExclusiveRunner

      public ExclusiveRunner()
  • Method Details

    • run

      public void run(Animation animation)

      Starts the animation passed by animation and executes the animation exactly once. If there is already an animation running in this instance, the animation will be canceled first and then the new animation will be started.

      Parameters:
      animation - The animation to run.
    • loop

      public void loop(Animation animation)

      Starts the animation and executes the animation in a loop infinitely. If there is already an animation running in this instance, the animation will be canceled first and then the new passed animation will be looped until either the method cancel() will be called or a new animation is set.

      Parameters:
      animation - The animation to loop.
    • cancel

      public void cancel()

      Cancels the actual animation that runs in the runner's context. The animation is stopped and destroyed. In order to continue a new animation has to be restarted by using either the run() or the loop() method.