Package com.badlogic.gdx.utils
Class Timer
- java.lang.Object
-
- com.badlogic.gdx.utils.Timer
-
public class Timer extends java.lang.ObjectExecutes tasks in the future on the main loop thread.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTimer.TaskRunnable that can be scheduled on aTimer.
-
Constructor Summary
Constructors Constructor Description Timer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Cancels all tasks.voiddelay(long delayMillis)Adds the specified delay to all tasks.static Timerinstance()Timer instance singleton for general application wide usage.booleanisEmpty()Returns true if the timer has no tasks in the queue.static Timer.Taskpost(Timer.Task task)Schedules a task oninstance().Timer.TaskpostTask(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.Taskschedule(Timer.Task task, float delaySeconds)Schedules a task oninstance().static Timer.Taskschedule(Timer.Task task, float delaySeconds, float intervalSeconds)Schedules a task oninstance().static Timer.Taskschedule(Timer.Task task, float delaySeconds, float intervalSeconds, int repeatCount)Schedules a task oninstance().Timer.TaskscheduleTask(Timer.Task task, float delaySeconds)Schedules a task to occur once after the specified delay.Timer.TaskscheduleTask(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.Timer.TaskscheduleTask(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.voidstart()Starts the timer if it was stopped.voidstop()Stops the timer, tasks will not be executed and time that passes will not be applied to the task delays.
-
-
-
Method Detail
-
instance
public static Timer instance()
Timer instance singleton for general application wide usage. Static methods onTimermake convenient use of this instance.
-
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.
-
post
public static Timer.Task post(Timer.Task task)
Schedules a task oninstance().- See Also:
postTask(Task)
-
schedule
public static Timer.Task schedule(Timer.Task task, float delaySeconds)
Schedules a task oninstance().- See Also:
scheduleTask(Task, float)
-
schedule
public static Timer.Task schedule(Timer.Task task, float delaySeconds, float intervalSeconds)
Schedules a task oninstance().- See Also:
scheduleTask(Task, float, float)
-
schedule
public static Timer.Task schedule(Timer.Task task, float delaySeconds, float intervalSeconds, int repeatCount)
Schedules a task oninstance().- See Also:
scheduleTask(Task, float, float, int)
-
-