Timers and time
Many things depend on time: an enemy every 2 seconds, a power-up that ends after 5.
The game timer
A timer counts seconds from when you start it. It has a name.
| Conditions | Actions |
|---|---|
| At the beginning of the layout | Start (or reset) the timer "Enemy" |
The timer "Enemy" > 2 seconds |
Create an object Enemy Start (or reset) the timer "Enemy" |
The Platformer example uses this pattern for the coin sound's pitch.
At the beginning of the layout runs once, on the first frame: a good place to set the game up.
Object timers
Each object also has its own timers (Start (or reset) an object timer, Value of an object timer). Use them when every instance needs its own time, such as each bomb with its own fuse.
Time behaviors
Without events:
- Every X seconds does something at regular intervals.
- Timer counts the object's time.
- Flash and Fade animate the look for a while.
Counting play time
Use a number variable and add the frame time:
| Conditions | Actions |
|---|---|
| (none) | Change variable value Time + TimeDelta() |
Tip: never count frames to measure time: the frames per second change from computer to computer. Use timers or
TimeDelta().