Class: rlLogicTimer

rlLogicTimer

new rlLogicTimer()

Meant to be used primarily from a Blob inside a Worker but can be instantiated and used directly as well. Provides steady timing by calling a user defined callback at a fixed interval and passing a tick count each time.

See:

Methods

(static) postMessage(messageData)

Send a message to the rlLogicTimer instance to configure its behaviour.

Parameters:
Name Type Description
messageData string | number

pass a number to change the timer interval (in ms) or one of the command strings "start", "stop", "resettick" | pass any other string to change the internal name of the timer (appears in console messages)

(static) setCallback(func)

Set the callback function to call on each timer tick when using the timer instance directly without a Worker.

Parameters:
Name Type Description
func rlLogicTimer~callbackOnTick

the callback function to call on each timer tick

Type Definitions

callbackOnTick(tick)

Function signature for callbacks to use with rlLogicTimer.setCallback.

Parameters:
Name Type Description
tick number

the current timer tick (increases by 1 with each call)