Package arc.util

Class Timer

java.lang.Object
arc.util.Timer

public class Timer extends Object
Executes tasks in the future on the main loop thread.
  • Constructor Details

    • Timer

      public Timer()
  • Method Details

    • instance

      public static Timer instance()
      Timer instance singleton for general application wide usage. Static methods on Timer make convenient use of this instance.
    • post

      public static Timer.Task post(Timer.Task task)
      Schedules a task on instance().
      See Also:
    • schedule

      public static Timer.Task schedule(Timer.Task task, float delaySeconds)
      Schedules a task on instance().
      See Also:
    • schedule

      public static Timer.Task schedule(Timer.Task task, float delaySeconds, float intervalSeconds)
      Schedules a task on instance().
      See Also:
    • schedule

      public static Timer.Task schedule(Timer.Task task, float delaySeconds, float intervalSeconds, int repeatCount)
      Schedules a task on instance().
      See Also:
    • schedule

      public static Timer.Task schedule(Runnable task, float delaySeconds)
      Schedules a task on instance().
      See Also:
    • schedule

      public static Timer.Task schedule(Runnable task, float delaySeconds, float intervalSeconds)
      Schedules a task on instance().
      See Also:
    • schedule

      public static Timer.Task schedule(Runnable task, float delaySeconds, float intervalSeconds, int repeatCount)
      Schedules a task on instance().
      See Also:
    • postTask

      public Timer.Task postTask(Timer.Task task)
      Schedules a task to occur once as soon as possible, but not sooner than the start of the next frame.
    • scheduleTask

      public Timer.Task scheduleTask(Timer.Task task, float delaySeconds)
      Schedules a task to occur once after the specified delay.
    • scheduleTask

      public Timer.Task scheduleTask(Timer.Task task, float delaySeconds, float intervalSeconds)
      Schedules a task to occur once after the specified delay and then repeatedly at the specified interval until cancelled.
    • scheduleTask

      public Timer.Task scheduleTask(Timer.Task task, float delaySeconds, float intervalSeconds, int repeatCount)
      Schedules a task to occur once after the specified delay and then a number of additional times at the specified interval.
      Parameters:
      repeatCount - If negative, the task will repeat forever.
    • stop

      public void stop()
      Stops the timer, tasks will not be executed and time that passes will not be applied to the task delays.
    • start

      public void start()
      Starts the timer if it was stopped.
    • clear

      public void clear()
      Cancels all tasks.
    • isEmpty

      public boolean isEmpty()
      Returns true if the timer has no tasks in the queue. Note that this can change at any time. Synchronize on the timer instance to prevent tasks being added, removed, or updated.
    • delay

      public void delay(long delayMillis)
      Adds the specified delay to all tasks.