Class: TimeStep

Phaser.Core. TimeStep

[description]


new TimeStep(game, config)

Parameters:
Name Type Description
game Phaser.Game

A reference to the Phaser.Game instance that owns this Time Step.

config FPSConfig
Since: 3.0.0
Source: src/core/TimeStep.js (Line 31)

Members


<readonly> actualFps :integer

An exponential moving average of the frames per second.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 60
Source: src/core/TimeStep.js (Line 140)

callback :TimeStepCallback

A callback to be invoked each time the Time Step steps.

Type:
Since: 3.0.0
Default Value:
  • NOOP
Source: src/core/TimeStep.js (Line 173)

delta :integer

[description]

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/core/TimeStep.js (Line 269)

deltaHistory :Array.<integer>

[description]

Type:
  • Array.<integer>
Since: 3.0.0
Source: src/core/TimeStep.js (Line 289)

deltaIndex :integer

[description]

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/core/TimeStep.js (Line 279)

deltaSmoothingMax :integer

[description]

Type:
  • integer
Since: 3.0.0
Default Value:
  • 10
Source: src/core/TimeStep.js (Line 298)

<readonly> forceSetTimeOut :boolean

You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting the forceSetTimeOut property to true in the Game Configuration object. It cannot be changed at run-time.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/core/TimeStep.js (Line 183)

<readonly> frame :integer

[description]

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/core/TimeStep.js (Line 225)

<readonly> framesThisSecond :integer

The number of frames processed this second.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/core/TimeStep.js (Line 162)

<readonly> game :Phaser.Game

A reference to the Phaser.Game instance.

Type:
Since: 3.0.0
Source: src/core/TimeStep.js (Line 49)

<readonly> inFocus :boolean

[description]

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/core/TimeStep.js (Line 236)

lastTime :integer

[description]

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/core/TimeStep.js (Line 215)

minFps :integer

The minimum fps rate you want the Time Step to run at.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 5
Source: src/core/TimeStep.js (Line 94)

<readonly> nextFpsUpdate :integer

[description]

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/core/TimeStep.js (Line 151)

panicMax :integer

[description]

Type:
  • integer
Since: 3.0.0
Default Value:
  • 120
Source: src/core/TimeStep.js (Line 308)

<readonly> raf :Phaser.DOM.RequestAnimationFrame

[description]

Type:
Since: 3.0.0
Source: src/core/TimeStep.js (Line 59)

rawDelta :number

The actual elapsed time in ms between one update and the next. Unlike with delta no smoothing, capping, or averaging is applied to this value. So please be careful when using this value in calculations.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/core/TimeStep.js (Line 318)

<readonly> running :boolean

A flag that is set once the TimeStep has started running and toggled when it stops. The difference between this value and started is that running is toggled when the TimeStep is sent to sleep, where-as started remains true, only changing if the TimeStep is actually stopped, not just paused.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/core/TimeStep.js (Line 80)

<readonly> started :boolean

A flag that is set once the TimeStep has started running and toggled when it stops.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/core/TimeStep.js (Line 69)

startTime :integer

[description]

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/core/TimeStep.js (Line 205)

targetFps :integer

The target fps rate for the Time Step to run at.

Setting this value will not actually change the speed at which the browser runs, that is beyond the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step is spiraling out of control.

Type:
  • integer
Since: 3.0.0
Default Value:
  • 60
Source: src/core/TimeStep.js (Line 104)

time :integer

[description]

Type:
  • integer
Since: 3.0.0
Default Value:
  • 0
Source: src/core/TimeStep.js (Line 195)

Methods


blur()

Called when the DOM window.onBlur event triggers.

Since: 3.0.0
Source: src/core/TimeStep.js (Line 331)

destroy()

Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null any objects.

Since: 3.0.0
Source: src/core/TimeStep.js (Line 638)

focus()

Called when the DOM window.onFocus event triggers.

Since: 3.0.0
Source: src/core/TimeStep.js (Line 342)

pause()

Called when the visibility API says the game is 'hidden' (tab switch out of view, etc)

Since: 3.0.0
Source: src/core/TimeStep.js (Line 355)

resetDelta()

[description]

Since: 3.0.0
Source: src/core/TimeStep.js (Line 379)

resume()

Called when the visibility API says the game is 'visible' again (tab switch back into view, etc)

Since: 3.0.0
Source: src/core/TimeStep.js (Line 366)

sleep()

Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the running flag to false.

Since: 3.0.0
Source: src/core/TimeStep.js (Line 577)

start(callback)

Starts the Time Step running, if it is not already doing so. Called automatically by the Game Boot process.

Parameters:
Name Type Description
callback TimeStepCallback

The callback to be invoked each time the Time Step steps.

Since: 3.0.0
Source: src/core/TimeStep.js (Line 408)

step(time)

The main step method. This is called each time the browser updates, either by Request Animation Frame, or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. You generally should never call this method directly.

Parameters:
Name Type Description
time number

The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.

Since: 3.0.0
Source: src/core/TimeStep.js (Line 441)

stop()

Stops the TimeStep running.

Since: 3.0.0
Source: src/core/TimeStep.js (Line 620)
Returns:

The TimeStep object.

Type
Phaser.Core.TimeStep

tick()

Manually calls TimeStep.step, passing in the performance.now value to it.

Since: 3.0.0
Source: src/core/TimeStep.js (Line 566)

wake( [seamless])

Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the running flag to true. The seamless argument controls if the wake-up should adjust the start time or not.

Parameters:
Name Type Argument Default Description
seamless boolean <optional>
false

Adjust the startTime based on the lastTime values.

Since: 3.0.0
Source: src/core/TimeStep.js (Line 593)