FlixelTimerManager
View sourceclass
org.flixelgdx.util.timer.FlixelTimerManager
Owns active FlixelTimer instances and advances them once per frame. Extends FlixelBasic like HaxeFlixel plugin-style managers so FlixelTimerManager.active, FlixelTimerManager.exists, FlixelTimerManager.kill, and FlixelTimerManager.destroy() gate FlixelTimerManager.update(float) the same way as other Flixel objects.
Use FlixelTimer.getGlobalManager() with FlixelGame (already wired) or construct a dedicated manager for isolated groups (for example add it to a FlixelState).
Timers are backed by a Pool to avoid per-delay allocations. FlixelTimerManager.start(...) obtains from the pool; FlixelTimer.cancel() and completed runs return instances to the pool.
Constructors
FlixelTimerManager()
Creates a new timer manager with a default pool of capacity 32.
Fields
activeTimers
Timers currently stepped by FlixelTimerManager.update(float). Named activeTimers to avoid clashing with FlixelTimerManager.active.
pool
Methods
start(float, FlixelTimerListener, int)
Starts a pooled timer registered with this manager.
Parameters:
| Name | Description |
|---|---|
timeSeconds | See the documentation for FlixelTimer.start(...). |
onComplete | Optional callback (each loop, including the last). |
loopCount | 0 for infinite. |
Returns: The started timer.
start(float, FlixelTimerListener)
Starts a pooled timer registered with this manager.
Parameters:
| Name | Description |
|---|---|
timeSeconds | The time to complete the timer. |
onComplete | The callback to run when the timer completes. |
Returns: The timer.
update(float)
draw(FlixelBatch)
destroy()
addIfMissing(FlixelTimer)
Adds a timer to the active list if it is not already present.
Parameters:
| Name | Description |
|---|---|
t | The timer to add. |
detachOnly(FlixelTimer)
Removes the timer from the active list without returning it to the pool (used before restart).
Parameters:
| Name | Description |
|---|---|
t | The timer to remove. |
removeAndFree(FlixelTimer)
Removes the timer from the active list and frees it from the pool.
Parameters:
| Name | Description |
|---|---|
t | The timer to remove. |
finishLast(FlixelTimer, FlixelTimerListener)
Removes the timer from the active list, invokes the listener, then returns the instance to the pool. Used for the final iteration so the callback sees a finished timer that is no longer managed.
Parameters:
| Name | Description |
|---|---|
t | The timer to finish. |
cb | The callback to run when the timer finishes. |
cancelAll()
Stops every running timer and returns instances to the pool.
completeAll()
Completes all active timers in the manager.