Package arc.util
Class Timer
java.lang.Object
arc.util.Timer
Executes tasks in the future on the main loop thread.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Cancels all tasks.void
delay
(long delayMillis) Adds the specified delay to all tasks.static Timer
instance()
Timer instance singleton for general application wide usage.boolean
isEmpty()
Returns true if the timer has no tasks in the queue.static Timer.Task
post
(Timer.Task task) Schedules a task oninstance()
.postTask
(Timer.Task task) Schedules a task to occur once as soon as possible, but not sooner than the start of the next frame.static Timer.Task
schedule
(Timer.Task task, float delaySeconds) Schedules a task oninstance()
.static Timer.Task
schedule
(Timer.Task task, float delaySeconds, float intervalSeconds) Schedules a task oninstance()
.static Timer.Task
schedule
(Timer.Task task, float delaySeconds, float intervalSeconds, int repeatCount) Schedules a task oninstance()
.static Timer.Task
Schedules a task oninstance()
.static Timer.Task
Schedules a task oninstance()
.static Timer.Task
Schedules a task oninstance()
.scheduleTask
(Timer.Task task, float delaySeconds) Schedules a task to occur once after the specified delay.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
(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.void
start()
Starts the timer if it was stopped.void
stop()
Stops the timer, tasks will not be executed and time that passes will not be applied to the task delays.
-
Constructor Details
-
Timer
public Timer()
-
-
Method Details
-
instance
Timer instance singleton for general application wide usage. Static methods onTimer
make convenient use of this instance. -
post
Schedules a task oninstance()
.- See Also:
-
schedule
Schedules a task oninstance()
.- See Also:
-
schedule
Schedules a task oninstance()
.- See Also:
-
schedule
public static Timer.Task schedule(Timer.Task task, float delaySeconds, float intervalSeconds, int repeatCount) Schedules a task oninstance()
.- See Also:
-
schedule
Schedules a task oninstance()
.- See Also:
-
schedule
Schedules a task oninstance()
.- See Also:
-
schedule
public static Timer.Task schedule(Runnable task, float delaySeconds, float intervalSeconds, int repeatCount) Schedules a task oninstance()
.- See Also:
-
postTask
Schedules a task to occur once as soon as possible, but not sooner than the start of the next frame. -
scheduleTask
Schedules a task to occur once after the specified delay. -
scheduleTask
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.
-