Game Development Reference
In-Depth Information
super();
}
protected function initSkinner():void {
new HelloSkinner();
}
Since the Pulse server is capable of serving multiple games, we need to override the
getGameId method and provide a string that must be unique among all the games
hosted by the server.
public override function getGameId():String {
return "HelloWorld";
}
In order to connect to the server for sending and receiving messages, we need to
create the Pulse level class instance called GameClient . To instantiate the network
communication client, it also needs the instance of the generated factory class.
protected override function initNetClient():void {
var factory:GNetClientObjectFactory;
factory = new GNetClientObjectFactory();
m_netClient = new GameClient(factory, this);
}
In the Hello World example, we will modify only two screens—one screen where a
new room is created and another the game screen. We will leave all the other screens
such as lobby, high scores, and register as they are.
protected override function initNewGameScreen():void {
m_newGameScreen = new NewGameRoomScreen();
m_newGameScreen.init();
}
protected override function initGameScreen():void {
m_gameScreen = new HelloGameScreen();
m_gameScreen.init();
}
Whenever a new game state arrives, an existing one is removed or modified,
the corresponding methods on the PulseGame are invoked. Remember that this
HelloGame class inherits from PulseGame, so we can simply override these methods
and pass it to the game screen for update.
public override function
onNewGameState(gameState:GameStateClient):void {
(m_gameScreen as HelloGameScreen).onAddGS(gameState);
}
public override function
onUpdateGameState(gameState:GameStateClient):void {
 
Search WWH ::




Custom Search