Time
world.time
contains the following properties:
Property | Description |
---|---|
world.time.elapsed | The number of milliseconds the world has been running for, excluding time spent while the world was paused. |
world.time.delta | The number of milliseconds since the previous frame, excluding time jumps due to being paused. |
world.time.absolute | The number of milliseconds that have elapsed since the world was created. |
world.time.absoluteDelta | The number of milliseconds since the last frame, including large jumps of time if the world is resuming after being paused. |
Start timer
const timeout = world.time.setTimeout(() => {
console.log('1000 ms have passed!')
}, 1000)
Clear timer
world.time.clearTimeout(timeout)
Intervals
Intervals (indefinitely repeating timers) work the same way:
const interval = world.time.setInterval(() => {
console.log('Another 1000 ms have passed!') // This will be logged repeatedly
}, 1000)