Class: RequestAnimationFrame

Phaser.DOM. RequestAnimationFrame

Abstracts away the use of RAF or setTimeOut for the core game update loop. This is invoked automatically by the Phaser.Game instance.


new RequestAnimationFrame()

Since: 3.0.0
Source: src/dom/RequestAnimationFrame.js (Line 10)

Members


callback :FrameRequestCallback

The callback to be invoked each step.

Type:
  • FrameRequestCallback
Since: 3.0.0
Source: src/dom/RequestAnimationFrame.js (Line 36)

isRunning :boolean

True if RequestAnimationFrame is running, otherwise false.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/dom/RequestAnimationFrame.js (Line 26)

isSetTimeOut :boolean

True if the step is using setTimeout instead of RAF.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/dom/RequestAnimationFrame.js (Line 55)

lastTime :number

The previous time the step was called.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/dom/RequestAnimationFrame.js (Line 75)

step :FrameRequestCallback

The RAF step function. Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame.

Type:
  • FrameRequestCallback
Since: 3.0.0
Source: src/dom/RequestAnimationFrame.js (Line 87)

stepTimeout :function

The SetTimeout step function. Updates the local tick value, invokes the callback and schedules another call to setTimeout.

Type:
  • function
Since: 3.0.0
Source: src/dom/RequestAnimationFrame.js (Line 110)

tick :number

The most recent timestamp. Either a DOMHighResTimeStamp under RAF or Date.now under SetTimeout.

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/dom/RequestAnimationFrame.js (Line 45)

<nullable> timeOutID :number

The setTimeout or RAF callback ID used when canceling them.

Type:
  • number
Since: 3.0.0
Default Value:
  • null
Source: src/dom/RequestAnimationFrame.js (Line 65)

Methods


destroy()

Stops the step from running and clears the callback reference.

Since: 3.0.0
Source: src/dom/RequestAnimationFrame.js (Line 179)

start(callback, forceSetTimeOut)

Starts the requestAnimationFrame or setTimeout process running.

Parameters:
Name Type Description
callback FrameRequestCallback

The callback to invoke each step.

forceSetTimeOut boolean

Should it use SetTimeout, even if RAF is available?

Since: 3.0.0
Source: src/dom/RequestAnimationFrame.js (Line 134)

stop()

Stops the requestAnimationFrame or setTimeout from running.

Since: 3.0.0
Source: src/dom/RequestAnimationFrame.js (Line 159)