Kiwi.Utils.RequestAnimationFrame Class
Abstracts away the use of RAF or setTimeout for the core game update loop. The callback can be re-mapped on the fly.
Constructor
Kiwi.Utils.RequestAnimationFrame
-
callback
Parameters:
-
callback
Any
Returns:
This object.
Item Index
Properties
Methods
objType
()
String
public
The type of obect that this is.
Returns:
"RequestAnimationFrame"
RAFUpdate
()
public
The update loop that the RAF will continuously call.
setCallback
-
callback
Sets the callback method that is to be executed each time the RAF is.
Parameters:
-
callback
Any
SetTimeoutUpdate
()
public
The update loop that the setTimeout method will continuously call.
start
-
[callback]
Starts the RequestAnimationFrame (or setTimeout if RAF not supported).
Parameters:
-
[callback]
Any optionalA callback to be executed everyframe. Overrides the callback set at instantiation if passed.
stop
()
public
Stops the RAF from running.
usingRAF
()
Boolean
public
Returns a boolean indicating wheather or not we are using the RAF. If false it means we are using setTimeout for our update loop.
Returns:
usingSetTimeOut
()
Boolean
public
Returns a boolean indicating whether or not setTimeout is being used instead of RAF.
Returns:
Properties
_callback
Any
private
The callback method that gets executed every time the RAF is executed.
_isSetTimeOut
Boolean
private
A boolean indicating whether or not we are using setTimeout for the RequestAnimationFrame or not.
Default: false
_rafId
???
private
ID of the RAF, used to stop the RAF
Default: null
_timeOutID
Any
private
If the RAF is not supported, then this is the ID of the timeout that will be set.
currentTime
Number
public
A timestamp that has the current time. This is updated each time the RAF loop is executed. Is updated before the last time in the loop.
isRunning
Boolean
public
A boolean indicating whether or not the RAF is running.
Default: false
lastTime
Number
public
The last time at which the RAF was called. This is given a value at the end of the RAF loop.