Game Development Reference
In-Depth Information
Game state API
Once a player is in the game room, the player may add, remove, or update game states
based on the game state rules discussed earlier in the chapter. For adding a new game
state, you simply create a new game state and call the add API method, the same is
true for sendGameStateAction . However, if you are modifying or removing the game
state, you must pass the existing game state when calling the API methods.
In the case of any errors during the above game state method calls,
onGameStateError notification will be invoked. If the game state updates were
successful, one of the corresponding callback methods will be fired.
public function addGameState(newGameState:GameStateClient):void
The addGameState method adds a new state into the game. The game state ID must
be zero. Upon successfully adding the game state, the onAddGameState callback is
fired on all players within the room. A unique ID is set for the new game state. The
uniqueness is only among the game states for a given game instance (room). This
unique ID is different from the stateKey . The stateKey should be set for unique
game states as required for the specific game being implemented. If the game
state is unique and a previously added game state with the same key was found,
onGameStateError is fired on the requesting client and the game state will not be
propagated to other players in the room.
public function updateGameState(gameState:GameStateClient):void
The updateGameState method should be called to update an existing state in the
game. The game state with the ID must exist upon successfully updating the game
state. The onUpdateGameState callback is fired on all players within the room. If the
game state with the ID was not found on the server, then onGameStateError will be
fired on the requesting client and the game state update will not be propagated to
other players in the room.
public function removeGameState(gameState:GameStateClient):void
The removeGameState method should be called to remove an existing state from the
game. The game state with the ID must exist. Upon successful deletion of the game
state, the onRemoveGameState callback is fired on all players within the room. If the
game state with the ID was not found on the server, then onGameStateError will be
fired on the originator and the game state deletion will not be propagated to other
players in the room.
public function sendGameStateAction(gameState:GameStateClient):void
 
Search WWH ::




Custom Search