Gamalto

Fork me on GitHub

Object Timer Overview

Gamalto. Timer

new Gamalto.Timer(callback, rateopt, skipopt)

Manages a timer which updates the game by triggering actions at specific time.

Parameters
Name Type Attributes Description
callback TimingFunc

Function to be called on every frame.

rate number <optional>

Expected minimum frame rate before trying to skip frames. By default, a rate of 25 frames per second is used.

skip number <optional>

Value between 0 and 100 representing the percentage of frames to skip. By default, this parameter is set to 0 meaning that no frame skip will occur.

Implements
Extends

Members

tag :object

inherited

Utility property to exchange data between objects.

Inherited From

Methods

clone() object

inherited abstract

Clones the object. It will be shallow copy unless otherwise specfied.

Inherited From
Returns
  • New instance of the object. Defaults to null.

getElapsed()

Gets the immediate time elapsed since the last iteration.

setFPSWatcher(callback)

Sets the callback function which will receive the frame rate information.

Parameters
Name Type Description
callback FPSFunc

The function to be called on every frame counter update. Setting to null will disable the FPS counter.

setFrameRate(rate)

Sets the expected timer frame rate.

Parameters
Name Type Description
rate number

Positive interger value.

setSkipRatio(ratio)

Sets the amount of frame that should be automatically skipped if the frame rate cannot be honored.

Parameters
Name Type Description
ratio number

Positive interger value between 0, no frame skip, and 100 allowing full frame skip.

start(strictopt)

Starts the timer execution.

Parameters
Name Type Attributes Description
strict boolean <optional>

Whether to force maximum frame rate to the set value Useful for non time-based games.

stop()

Stops the timer execution.

toString() string

inherited abstract

Converts the object into a string.

Inherited From
Returns
  • string

Documentation generated by JSDoc 3.3.2 on Sun Sep 13 2015 20:13:31 GMT+0200 (CEST)