API Docs for: 1.4.0
Show:

Kiwi.Time.ClockManager Class

Module: Time
Parent Module: Kiwi

Handles the generation and tracking of Clock and time related applications for a single game.

An instance of ClockManager is automatically created as part of Kiwi.Game. This is accessible as the time property of any Game object. You should not need to create additional ClockManager objects.

If you do want to create additional ClockManager objects, be sure to call boot() after creation to set up properties like the master clock. You will also need to update this manager every frame.

Constructor

Kiwi.Time.ClockManager

(
  • game.
)
Kiwi.Time.ClockManager

Parameters:

Returns:

Kiwi.Time.ClockManager:

This Object.

Methods

addClock

(
  • name
  • [units=1000]
)
Kiwi.Time.Clock public

Creates a Clock class for keeping time relative to the MasterClock.

Parameters:

  • name String

    The name of the Clock.

  • [units=1000] Number optional

    The number of milliseconds that make up one unit of time on this clock. Default 1000.

Returns:

Kiwi.Time.Clock:

A reference to the newly created Clock object.

boot

() public

When all of the DOM elements that the game requires have loaded successfully then this object will 'boot'.

delta

() Number public

Returns the delta of the master clock.

Returns:

Number:

elapsed

() Number public

Defined in src\time\ClockManager.ts:169

Available since 1.1.0

Returns the elapsed time. Based on the master clock.

Returns:

Number:

getClock

(
  • name
)
Kiwi.Time.Clock public

Returns the Clock with the matching name. Throws an error if no Clock with that name exists

Parameters:

  • name String

    The name of the Clock to be returned.

Returns:

Kiwi.Time.Clock:

The clock which matches the name given.

now

() Number public

Returns the current time. Based on the master clock.

Returns:

Number:

objType

() String public

The type of object this is.

Returns:

String:

"ClockManager"

setMasterInterval

(
  • interval
)
public

Defined in src\time\ClockManager.ts:192

Available since 1.1.0

Sets the interval on the master clock.

Parameters:

  • interval Number

    The ideal frame interval in milliseconds.

update

() public

Is executed every frame and updates all of the clocks that exist on this manager.

Properties

_clocks

Array private

An array containing all of the clocks that exist on this manager.

_game

Kiwi.Game private

The game that this belongs to.

clock

Kiwi.Time.Clock public

The default Game Clock - you can use this via this.game.time.clock. Uses a 1000 millisecond time unit.

master

Kiwi.Time.MasterClock private

The MasterClock for this manager.

rate

Number public

Defined in src\time\ClockManager.ts:64

Available since 1.1.10

Frame rate factor, derived from master clock