essential.handleState
Prototype
function handleState(stateType, dataObject)
Input parameters
stateType - type of the state we are changing into
dataObject - data associated with the new state (can be null)
Return value
array defining the next state, or null if no next state should be set
Description
Handles a game state change. Should return an object with information of the next planned state change, or null if the game should be set to idle.
Returned object should be an associated array with the fields newstatetype, newdata and timenextstate. STARTGAME_STATE and ENDGAME_STATE are special, see the Programmers Guide for more information about handling states.
Example code
function handleState(stateType, dataObject)
{
if (stateType == STARTGAME_STATE)
{
// Handle the start game state
// ...
return {"newstatetype":STATE_NEXT_QUESTION, "newdata":null,
"timenextstate":0};
}
if (stateType == STATE_NEXT_QUESTION)
{
// ...
return {"newstatetype":ENDGAME_STATE,
"newdata":{"startnewwait": 8000 },
"timenextstate":0};
}
return null;
}
