Class Timer

java.lang.Object
rekit.primitives.time.Timer

public final class Timer extends Object
Data class that holds an duration time.
Author:
Angelo Aracri
  • Constructor Details

    • Timer

      public Timer(long duration)
      Create a TimeDependency by duration time.
      Parameters:
      duration - the duration time in millis
  • Method Details

    • logicLoop

      public void logicLoop()
      This method shall be invoked by the logic every GameConf.LOGIC_DELTA ms.
    • timeUp

      public boolean timeUp()
      Indicates whether the time is up.
      Returns:
      true if time is up; false otherwise
    • reset

      public void reset()
      Reset the time.
    • getProgress

      public float getProgress()
      Get current progress.
      Returns:
      percentage as float in [0,1]
    • offset

      public void offset(long offset)
      Subtract an offset at beginning.
      Parameters:
      offset - the offset
    • sleep

      public static void sleep(long offset)
      This method can be used instead of ThreadUtils.sleep(long) if GameTime.pause() shall take effect.
      Be careful: If game is paused, this method will cause endless waiting
      Parameters:
      offset - the time to wait in millis
    • execute

      public static void execute(int offset, Runnable r)
      This method can be used instead to execute a job after a specified time.
      Parameters:
      offset - the time to wait in millis
      r - the job