new GameLoop(p_update, p_render, p_reset, p_panic, p_document)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
p_update |
function | A model update function that is to be called exactly 60 times per second. | |
p_render |
function | A view render function that is to be called as often as possible up to 60 times per second. | |
p_reset |
function | null | A function to reset the game to an initial state. |
p_panic |
function | A function that is called if the state of the loop is
GameLoop.RUNNING and the model update function
is not called for at least one second. |
|
p_document |
Object | The document where the views are to be displayed. If the document looses the visibility focus, the game loop automatically is paused. |
- Source:
Members
-
<static> PAUSED
-
State of the game loop when the game loop has been paused by means of the function
pause.- Source:
-
<static> RUNNING
-
State of the game loop when the game loop has been started or continued by means of the function
startorcontinue.- Source:
-
<static> state
-
- Source:
-
<static> STATE_HAS_CHANGED_EVENT
-
State of the game loop when the game loop has been stopped by means of the function
stop. This is the default state, after the game loop has been initialized.- Source:
-
<static> STOPPED
-
State of the game loop when the game loop has been stopped by means of the function
stop. This is the default state, after the game loop has been initialized.- Source:
Methods
-
goOn()
-
Function to continue the game loop. This function has only an effect, if the current state of the game loop is
GameLoop.PAUSED.- Source:
-
pause()
-
Function to pause the game loop. This function has only an effect, if the current state of the game loop is
gameLoop.RUNNING.- Source:
-
start()
-
Function to start the game loop. This function has only an effect, if the current state of the game loop is
gameLoop.STOPPED.- Source:
-
stop()
-
Function to continue the game loop. This function has only an effect, if the current state of the game loop is not already
GameLoop.STOPPED.- Source:
Fires:
- GameLoop:state_has_changed