Game Development Reference
In-Depth Information
m_newGameScreen = new MyNewGameScreen();
m_newGameScreen.init();
}
Next, we subclass NewGameScreen defined in PulseUI called NewGameRoom
screen and override just one method called createNewGameRoom. In the method,
we specify what kind of room needs to be created. For this sample, we will keep it
real simple:
protected override function createNewGameRoom():void {
var room:GameRoomClient = new GameRoomClient();
room.setRoomName(m_ti.text);
room.setMaxPlayerCount(3);
room.setRoomType(GameConstants.ROOM_ALLOW_POST_START);
room.setAutoReady(1);
PulseGame.getInstance().getGameClient().
createGameRoom(room);
}
First, we create a game room object of class GameRoomClient , which is defined in the
Pulse package. We then set the properties on the object. We give it a name as entered
by the player and limit the number of players joining the room to three. We also set
the room type to say that players may join the room for which the game has already
started. We set the auto-ready to 1 (true) meaning the player status will be set to
ready as soon as they join the game, and this will allow the host to start the game
anytime. Note that, in this sample, we don't provide any UI to set the status of the
player to ready or wait .
Finally, we call the Pulse API createGameRoom(…) and pass the instance of the room.
Once the server creates the room successfully, the new room will appear for every
player that is currently in the lobby.
New game room API
To create a new game room as we saw in the HelloWorld example, you simply need
to create the room object, set the necessary properties, and call createGameRoom API.
public function createGameRoom(gameRoom:GameRoomClient):void
The game client will receive the following notification to let the game client know
if the request was successfully created or had any errors.
function onCreateGameRoom(gameRoomId:int, error:int):void;
Note that players in the lobby will be notified of the newly created room so that their
respective UI can be updated.
 
Search WWH ::




Custom Search