Class: Time

Phaser. Time

This is the core internal game clock. It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens.

new Time(game)

Time constructor.

Parameters:
Name Type Description
game Phaser.Game

A reference to the currently running game.

Source:

Members

<protected> elapsed

Properties:
Name Type Description
elapsed number

Elapsed time since the last frame (in ms).

Source:

events

Properties:
Name Type Description
events Phaser.Timer

This is a Phaser.Timer object bound to the master clock to which you can add timed events.

Source:

<protected> fps

Properties:
Name Type Description
fps number

Frames per second.

Source:

fpsMax

Properties:
Name Type Description
fpsMax number

The highest rate the fps has reached (usually no higher than 60fps).

Source:

fpsMin

Properties:
Name Type Description
fpsMin number

The lowest rate the fps has dropped to.

Source:

frames

Properties:
Name Type Description
frames number

The number of frames record in the last second.

Source:

game

Properties:
Name Type Description
game Phaser.Game

Local reference to game.

Source:

lastTime

Properties:
Name Type Description
lastTime number

Internal value used by timeToCall as part of the setTimeout loop

Source:

msMax

Properties:
Name Type Description
msMax number

The maximum amount of time the game has taken between two frames.

Source:

msMin

Properties:
Name Type Description
msMin number

The minimum amount of time the game has taken between two frames.

Default Value:
  • 1000
Source:

<protected> now

Properties:
Name Type Description
now number

The time right now.

Source:

<protected> pausedTime

Properties:
Name Type Description
pausedTime number

Records how long the game has been paused for. Is reset each time the game pauses.

Source:

pauseDuration

Properties:
Name Type Description
pauseDuration number

Records how long the game was paused for in miliseconds.

Source:

physicsElapsed

Properties:
Name Type Description
physicsElapsed number

The elapsed time calculated for the physics motion updates.

Source:

<protected> time

Properties:
Name Type Description
time number

Game time counter. If you need a value for in-game calculation please use Phaser.Time.now instead.

Source:

timeToCall

Properties:
Name Type Description
timeToCall number

The value that setTimeout needs to work out when to next update

Source:

Methods

boot()

Source:

create(autoDestroy) → {Phaser.Timer}

Creates a new stand-alone Phaser.Timer object.

Parameters:
Name Type Argument Default Description
autoDestroy boolean <optional>
true

A Timer that is set to automatically destroy itself will do so after all of its events have been dispatched (assuming no looping events).

Source:
Returns:

The Timer object that was created.

Type
Phaser.Timer

elapsedSecondsSince(since) → {number}

How long has passed since the given time (in seconds).

Parameters:
Name Type Description
since number

The time you want to measure (in seconds).

Source:
Returns:

Duration between given time and now (in seconds).

Type
number

elapsedSince(since) → {number}

How long has passed since the given time.

Parameters:
Name Type Description
since number

The time you want to measure against.

Source:
Returns:

The difference between the given time and now.

Type
number

removeAll()

Remove all Timer objects, regardless of their state.

Source:

reset()

Resets the private _started value to now.

Source:

totalElapsedSeconds() → {number}

The number of seconds that have elapsed since the game was started.

Source:
Returns:
Type
number

update(time)

Updates the game clock and calculate the fps. This is called automatically by Phaser.Game.

Parameters:
Name Type Description
time number

The current timestamp, either performance.now or Date.now depending on the browser.

Source:
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Mon Feb 24 2014 12:11:47 GMT-0000 (GMT) using the DocStrap template.