me.timer

a Timer object to manage time function (FPS, Game Tick, Time...)

There is no constructor function for me.timer

Members

static fps :Number

Last measured fps rate.
This feature is disabled by default. Load and enable the DebugPanel plugin to use it.

static lastUpdate :Date

Last update time.
Use this value to implement frame prediction in drawing events, for creating smooth motion while running game update logic at a lower fps.

static tick :Number

Last game tick value.
Use this value to scale velocities during frame drops due to slow hardware or when setting an FPS limit. (See me.sys.fps) This feature is disabled by default. Enable me.sys.interpolation to use it.

See:

Methods

static clearInterval(intervalID)

Clears the Interval set by me.timer.setInterval().

Parameters:
Name Type Description
intervalID Number

ID of the interval to be cleared

static clearTimeout(timeoutID)

Clears the delay set by me.timer.setTimeout().

Parameters:
Name Type Description
timeoutID Number

ID of the timeout to be cleared

static getDelta() → {Number}

Return elapsed time in milliseconds since the last update

Returns:
Number

static getTime() → {Number}

Return the current timestamp in milliseconds
since the game has started or since linux epoch (based on browser support for High Resolution Timer)

Returns:
Number

static setInterval(fn, delay, pauseableopt) → {Number}

Calls a function continously at the specified interval. See setTimeout to call function a single time.

Parameters:
Name Type Attributes Default Description
fn function

the function to execute

delay Number

the number of milliseconds (thousandths of a second) on how often to execute the function

pauseable Boolean <optional>
true

respects the pause state of the engine.

Returns:
Number -

The numerical ID of the timeout, which can be used later with me.timer.clearInterval().

static setTimeout(fn, delay, pauseableopt) → {Number}

Calls a function once after a specified delay. See me.timer.setInterval to repeativly call a function.

Parameters:
Name Type Attributes Default Description
fn function

the function you want to execute after delay milliseconds.

delay Number

the number of milliseconds (thousandths of a second) that the function call should be delayed by.

pauseable Boolean <optional>
true

respects the pause state of the engine.

Returns:
Number -

The numerical ID of the timeout, which can be used later with me.timer.clearTimeout().