Documentation
¶
Overview ¶
Command timer demonstrates the timer component as observable state. Three timers run side by side: a one-shot that fires once and stays readable, a repeating timer that restarts itself, and a timer created paused and started by a key press.
Timers advance on their own each fixed tick; a game never calls an update function on them. Completions are read straight from the component - timer.Timer.JustCompleted against the current tick is the completion edge, and timer.Timer.CompletedOn keeps the tick of the last fire for as long as it is useful. There are no events and no callbacks.
Each timer is its own entity, so any number of them can run for the same game: this program keeps three handles and reads them.
Run from the repository root:
go run ./examples/timer