Phaser. Time

new Time(game)

This is the core internal game clock.

It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens, and also handlers the standard Timer pool.

To create a general timed event, use the master Phaser.Timer accessible through events.

Parameters:
Name Type Description
game Phaser.Game

A reference to the currently running game.

Source - time/Time.js, line 19

Members

advancedTiming :boolean

If true then advanced profiling, including the fps rate, fps min/max and msMin/msMax are updated.

Default Value:
  • false
Source - time/Time.js, line 136

desiredFps :number

The desired frame rate of the game.

This is used is used to calculate the physic/logic multiplier and how to apply catch-up logic updates.

Default Value:
  • 60
Source - time/Time.js, line 110

<internal> elapsed :number

Elapsed time since the last time update, in milliseconds, based on now.

This value may include time that the game is paused/inactive.

Note: This is updated only once per game loop - even if multiple logic update steps are done. Use physicsTime as a basis of game/logic calculations instead.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 67
See:
  • Phaser.Time.time

<internal> elapsedMS :integer

The time in ms since the last time update, in milliseconds, based on time.

This value is corrected for game pauses and will be "about zero" after a game is resumed.

Note: This is updated once per game loop - even if multiple logic update steps are done. Use physicsTime as a basis of game/logic calculations instead.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 80

events :Phaser.Timer

A Phaser.Timer object bound to the master clock (this Time object) which events can be added to.

Source - time/Time.js, line 216

<readonly> fps :number

Advanced timing result: Frames per second.

Only calculated if advancedTiming is enabled.

Source - time/Time.js, line 154

fpsMax :number

Advanced timing result: The highest rate the fps has reached (usually no higher than 60fps).

Only calculated if advancedTiming is enabled. This value can be manually reset.

Source - time/Time.js, line 172

fpsMin :number

Advanced timing result: The lowest rate the fps has dropped to.

Only calculated if advancedTiming is enabled. This value can be manually reset.

Source - time/Time.js, line 163

<readonly> frames :integer

Advanced timing result: The number of render frames record in the last second.

Only calculated if advancedTiming is enabled.

Source - time/Time.js, line 145

<internal> game :Phaser.Game

Local reference to game.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 25

msMax :number

Advanced timing result: The maximum amount of time the game has taken between consecutive frames.

Only calculated if advancedTiming is enabled. This value can be manually reset.

Source - time/Time.js, line 191

msMin :number

Advanced timing result: The minimum amount of time the game has taken between consecutive frames.

Only calculated if advancedTiming is enabled. This value can be manually reset.

Default Value:
  • 1000
Source - time/Time.js, line 182

<internal> now :number

An increasing value representing cumulative milliseconds since an undisclosed epoch.

While this value is in milliseconds and can be used to compute time deltas, it must must not be used with Date.now() as it may not use the same epoch / starting reference.

The source may either be from a high-res source (eg. if RAF is available) or the standard Date.now; the value can only be relied upon within a particular game instance.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 53

pauseDuration :number

Records how long the game was last paused, in miliseconds. (This is not updated until the game is resumed.)

Source - time/Time.js, line 198

physicsElapsed :number

The physics update delta, in fractional seconds.

This should be used as an applicable multiplier by all logic update steps (eg. preUpdate/postUpdate/update) to ensure consistent game timing. Game/logic timing can drift from real-world time if the system is unable to consistently maintain the desired FPS.

With fixed-step updates this is normally equivalent to 1.0 / desiredFps.

Source - time/Time.js, line 93

physicsElapsedMS :number

The physics update delta, in milliseconds - equivalent to physicsElapsed * 1000.

Source - time/Time.js, line 100

<internal> prevTime :number

The now when the previous update occurred.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 39

slowMotion :number

Scaling factor to make the game move smoothly in slow motion - 1.0 = normal speed - 2.0 = half speed

Default Value:
  • 1.0
Source - time/Time.js, line 129

suggestedFps :number

The suggested frame rate for your game, based on an averaged real frame rate.

Note: This is not available until after a few frames have passed; use it after a few seconds (eg. after the menus)

Default Value:
  • null
Source - time/Time.js, line 120

<internal> time :integer

The Date.now() value when the time was last updated.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 32

<internal> timeExpected :number

The time when the next call is expected when using setTimer to control the update loop

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 210

<internal> timeToCall :number

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

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 204

Methods

add(timer) → {Phaser.Timer}

Adds an existing Phaser.Timer object to the Timer pool.

Parameters:
Name Type Description
timer Phaser.Timer

An existing Phaser.Timer object.

Returns:

The given Phaser.Timer object.

Source - time/Time.js, line 278

<internal> boot()

Called automatically by Phaser.Game after boot. Should not be called directly.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 264

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).

Returns:

The Timer object that was created.

Source - time/Time.js, line 293

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).

Returns:
number -

Duration between given time and now (in seconds).

Source - time/Time.js, line 491

elapsedSince(since) → {number}

How long has passed since the given time.

Parameters:
Name Type Description
since number

The time you want to measure against.

Returns:
number -

The difference between the given time and now.

Source - time/Time.js, line 480

removeAll()

Remove all Timer objects, regardless of their state and clears all Timers from the events timer.

Source - time/Time.js, line 312

reset()

Resets the private _started value to now and removes all currently running Timers.

Source - time/Time.js, line 502

totalElapsedSeconds() → {number}

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

Returns:
number -

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

Source - time/Time.js, line 470

<internal> update(time)

Updates the game clock and if enabled the advanced timing data. This is called automatically by Phaser.Game.

Parameters:
Name Type Description
time number

The current relative timestamp; see now.

Internal:
  • This member is internal (protected) and may be modified or removed in the future.
Source - time/Time.js, line 330
Phaser Copyright © 2012-2014 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Wed Dec 03 2014 10:31:06 GMT-0000 (GMT) using the DocStrap template.