world.time
Description
World time.
Functions
Function | Description |
---|---|
setTimeout | Sets a timer which executes a function or specified piece of code once the timer expires. |
setInterval | Repeatedly calls a function or executes a code snippet, with a fixed time delay between each call. |
clearTimeout | Cancels a timeout previously established by calling setTimeout() . |
clearInterval | Cancels a timed, repeating action which was previously established by a call to setInterval() . |
Properties
Property | Description |
---|---|
elapsed | The number of milliseconds the world has been running for, excluding time spent while the world was paused. |
delta | The number of milliseconds since the previous frame, excluding time jumps due to being paused. |
absolute | The number of milliseconds that have elapsed since the world was created. |
absoluteDelta | The number of milliseconds since the last frame, including large jumps of time if the world is resuming after being paused. |
Examples
Timer
// start a timer
const timeout = world.time.setTimeout(() => {
console.log('1000 ms have passed!')
}, 1000)
// clear a timer
world.time.clearTimeout(timeout)
Interval
// start an interval
const interval = world.time.setInterval(() => {
console.log('Another 1000 ms have passed!') // This will be logged repeatedly
}, 1000)
// clear an interval
world.time.clearInterval(interval)