Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/tiny-engine/llms.txt
Use this file to discover all available pages before exploring further.
Timer is a lightweight, non-visual node that tracks elapsed time in seconds. Each frame the engine adds delta to an internal counter; when the counter reaches duration, the node fires timeout and stops. You can start it automatically with autoPlay, or control it imperatively via play(), pause(), and stop().
Use Timer for cooldowns, respawn delays, timed events, countdowns, and any other game logic that needs to respond after a fixed number of seconds.
Usage
Props
Total duration in seconds. When the elapsed time reaches this value, the timer stops and fires
timeout. Reactive when a SignalGetter is passed — changing the signal updates duration without restarting the timer.When
true, play() is called automatically at the end of the constructor so the timer is running as soon as the scene loop’s first update() tick fires. Defaults to false.A ref created by
useRefNode(PrimaryNode.Timer). Exposes the Timer instance so you can call play(), pause(), and stop() imperatively.Optional node identifier. Must match
[a-zA-Z][a-zA-Z0-9-_]* when a string.Draw order among siblings. Defaults to
0.Speed multiplier applied to
delta for this node. Use values below 1 to slow the timer down or above 1 to speed it up. Defaults to 1.Optional child nodes. The timer itself has no visual output but can serve as a logical parent.
Events
Subscribe withuseEvent.
| Event name | Callback signature | Description |
|---|---|---|
timeout | () => void | Fires once when elapsed time reaches duration. |
timeChanged | (elapsed: number) => void | Fires every frame while the timer is running, before the increment. |
started | () => void | Fires once after the node finishes start(). |
updated | (delta: number) => void | Fires every frame during the update cycle. |
drawed | (delta: number) => void | Fires every frame during the draw cycle. |
destroyed | () => void | Fires once when the node is removed. |
timeChanged fires before the counter is incremented for that frame. On the final frame, timeout fires instead of timeChanged.Runtime methods
| Method | Signature | Description |
|---|---|---|
play(from?) | (from?: number) => void | Start or resume the timer. Pass a number to seek to that position (clamped to [0, duration]). |
pause() | () => void | Pause the timer without resetting elapsed time. |
stop() | () => void | Stop the timer and reset elapsed time to 0. |
Complete example — cooldown with progress display
Example — single-use delay
UseautoPlay when you just need a one-shot delay from the moment the node enters the scene:
Related
useRefNode— obtain a typed ref to accessplay(),pause(),stop()useEvent— subscribe totimeoutandtimeChangeduseSignal— store elapsed time or cooldown state reactivelyTransform— parent node for grouping the timer with other nodes