Zum Hauptinhalt springen

world.time

Description

World time.

Functions

FunctionDescription
setTimeoutSets a timer which executes a function or specified piece of code once the timer expires.
setIntervalRepeatedly calls a function or executes a code snippet, with a fixed time delay between each call.
clearTimeoutCancels a timeout previously established by calling setTimeout().
clearIntervalCancels a timed, repeating action which was previously established by a call to setInterval().

Properties

PropertyDescription
elapsedThe number of milliseconds the world has been running for, excluding time spent while the world was paused.
deltaThe number of milliseconds since the previous frame, excluding time jumps due to being paused.
absoluteThe number of milliseconds that have elapsed since the world was created.
absoluteDeltaThe 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)