Class Index | File Index

Classes


Class VENISON.GAMESTATES.GameStateManager

Singleton used for managing the states of the game.
Defined in: venison_engine.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
fnHandleEvent(iEvent)
Let the current state handle events.
 
fnRegisterGameState(iGameState, iName)
Register a game state with the GameStateManager.
 
fnSetState(iName)
Set the current state of the game.
Class Detail
VENISON.GAMESTATES.GameStateManager()
Method Detail
fnHandleEvent(iEvent)
Let the current state handle events.
Parameters:
{Object} iEvent
The event. Note that this could be anything, so it could be used very dynamically.

fnRegisterGameState(iGameState, iName)
Register a game state with the GameStateManager.
//Template for implementing a new game state
new
function () {
   var mName = 'AnotherState';
   //Called once when entering this state
   this.fnOnEnter = function () {
   	//Do stuff here.
   }
   //Called once when leaving this state
   this.fnOnLeave = function () {
   	//Do stuff here.
   }
   //Returns the name of the game state to use next frame
   this.fnOnFrame = function () {
   	//Do stuff here.
   	return mName;
   }
	 //Called via {@link VENISON.GAMESTATES.GameStateManager#fnHandleEvent} if this is the current state.
	 //@param {Object} iEvent The event, could be anything!
	 this.fnHandleEvent = function (iEvent) {
		//Handle the event here.
	 }
   //Register this state with the game state manager (no need to change when creating a new state)
   GameStateManager.fnRegisterGameState(this,mName);
}
Parameters:
{Function} iGameState
The game state.
{String} iName
The name of the game state.

fnSetState(iName)
Set the current state of the game. The previous game state will get an opportunity to do stuff before it is replaced.
Parameters:
{String} iName
The name of the state.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu May 05 2011 18:47:28 GMT+0200 (CEST)