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.
Parameters:
Name | Type | Description |
---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
- Source - time/Time.js, line 15
Members
-
advancedTiming :boolean
-
If true Phaser.Time will perform advanced profiling including the fps rate, fps min/max and msMin and msMax.
- Default Value:
- false
- Source - time/Time.js, line 86
-
deltaCap :number
-
If you need to cap the delta timer, set the value here. For 60fps the delta should be 0.016, so try variances just above this.
- Source - time/Time.js, line 123
-
desiredFps :number
-
= 60 - The desired frame-rate for this project.
- Source - time/Time.js, line 56
-
<internal> elapsed :number
-
Elapsed time since the last frame (in ms).
- Internal:
- This member is internal (protected) and may be modified or removed in the future.
- Source - time/Time.js, line 45
-
events :Phaser.Timer
-
This is a Phaser.Timer object bound to the master clock to which you can add timed events.
- Source - time/Time.js, line 156
-
<internal> fps :number
-
Frames per second. Only calculated if Time.advancedTiming is true.
- Internal:
- This member is internal (protected) and may be modified or removed in the future.
- Source - time/Time.js, line 92
-
fpsMax :number
-
The highest rate the fps has reached (usually no higher than 60fps). Only calculated if Time.advancedTiming is true.
- Source - time/Time.js, line 102
-
fpsMin :number
-
The lowest rate the fps has dropped to. Only calculated if Time.advancedTiming is true.
- Source - time/Time.js, line 97
-
frames :number
-
The number of frames record in the last second. Only calculated if Time.advancedTiming is true.
- Source - time/Time.js, line 136
-
game :Phaser.Game
-
Local reference to game.
- Source - time/Time.js, line 20
-
msMax :number
-
The maximum amount of time the game has taken between two frames. Only calculated if Time.advancedTiming is true.
- Source - time/Time.js, line 113
-
msMin :number
-
The minimum amount of time the game has taken between two frames. Only calculated if Time.advancedTiming is true.
- Default Value:
- 1000
- Source - time/Time.js, line 108
-
<internal> now :number
-
The time right now.
- Internal:
- This member is internal (protected) and may be modified or removed in the future.
- Source - time/Time.js, line 39
-
<internal> pausedTime :number
-
Records how long the game has been paused for. Is reset each time the game pauses.
- Internal:
- This member is internal (protected) and may be modified or removed in the future.
- Source - time/Time.js, line 51
-
pauseDuration :number
-
Records how long the game was paused for in miliseconds.
- Source - time/Time.js, line 141
-
physicsElapsed :number
-
The elapsed time calculated for the physics motion updates. In a stable 60fps system this will be 0.016 every frame.
- Source - time/Time.js, line 118
-
<internal> prevTime :number
-
The time the previous update occurred.
- Internal:
- This member is internal (protected) and may be modified or removed in the future.
- Source - time/Time.js, line 33
-
slowMotion :Number
-
= 1.0 - Scaling factor to make the game move smoothly in slow motion (1.0 = normal speed, 2.0 = half speed)
- Source - time/Time.js, line 80
-
suggestedFps :number
-
= null - The suggested frame-rate for this project. NOTE: not available until after a few frames have passed, it is recommended to use this after a few seconds (eg. after the menus)
- Source - time/Time.js, line 62
-
<internal> time :number
-
Game time counter. If you need a value for in-game calculation please use Phaser.Time.now instead. - This always contains Date.now, but Phaser.Time.now will hold the high resolution RAF timer value (if RAF is available)
- Internal:
- This member is internal (protected) and may be modified or removed in the future.
- Source - time/Time.js, line 27
-
timeCap :number
-
If the difference in time between two frame updates exceeds this value in ms, the frame time is reset to avoid huge elapsed counts. - assumes a desiredFps of 60
DEPRECATED: this no longer has any effect since the change to fixed-time stepping in game.update 3rd November 2014
- Source - time/Time.js, line 131
-
timeExpected :number
-
The time when the next call is expected when using setTimer to control the update loop
- Source - time/Time.js, line 151
-
timeToCall :number
-
The value that setTimeout needs to work out when to next update
- Source - time/Time.js, line 146
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 217
-
<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 204
-
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 232
-
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 427
-
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 416
-
removeAll()
-
Remove all Timer objects, regardless of their state. Also clears all Timers from the Time.events timer.
- Source - time/Time.js, line 251
-
reset()
-
Resets the private _started value to now and removes all currently running Timers.
- Source - time/Time.js, line 438
-
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 406
-
<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 timestamp.
- Internal:
- This member is internal (protected) and may be modified or removed in the future.
- Source - time/Time.js, line 269