Skip to content

Methods

start()

Starts the time system. Once enabled, global nodes begin to participate in the update cycle.


isRunning()

Checks if the time system is currently running.


setTimeScale()

Sets the dt time scale factor. You can use this to speed up or slow down the passage of time.

The default value is 1.0. A value greater than 1 means acceleration, and a value less than 1 means deceleration.

Note: The time scale factor affects the time updates of all nodes, including global nodes.

Please use the time scale factor with caution to avoid unexpected behavior.

Warning: The time scale factor may cause time inconsistencies between nodes, which could lead to game logic errors.

Input Parameters

ParameterRequiredDefaultTypeDescription
scaleYesnumberThe time scale factor

getTimeScale()

Gets the dt time scale factor.


setTimeout()

Adds a delayed task. The update rate is the same as the node's update frequency.

Input Parameters

ParameterRequiredDefaultTypeDescription
callbackYes()=>voidThe callback function
delayYesnumberThe delay time in milliseconds

Return Value

TypeDescription
numberThe task ID

clearTimeout()

Clears a delayed task.

Input Parameters

ParameterRequiredDefaultTypeDescription
taskIdYesnumberThe task ID

stop()

Temporarily stops the time system.


applyTimeWarp()

Applies a time warp effect.

Input Parameters

ParameterRequiredDefaultTypeDescription
intensityYesnumberThe time warp intensity
durationYesnumberThe duration in milliseconds

神岛实验室