Game Development Reference
In-Depth Information
The JigsawGame class
This is the main class where the game code begins. This is also the place where we
tell the Pulse UI of the game about the specific classes that are being overridden, for
example, the following three classes.
Overriding the constructor
The constructor is a good place to instantiate the game-specific skinner class; more on
implementing the skinner class is discussed later. We also set the super-class defined
as s_instance to this, so any reference to the singleton points is to our subclass
instead of the parent.
public function JigsawGame()
{
s_instance = this;
new JigsawSkinner();
super();
}
Override the getGameId method from PulseGame as follows:
public override function getGameId():String {
return "Jigsaw-MP";
}
The Pulse runtime needs a unique game ID for each game, since many games could
be hosted on a single server. This ID is also used by the server to match other players
playing the same game. This means players of jigsaw will not be able to go into a
room that is playing tic-tac-toe.
Overriding the initNetClient method
This is the main API class instance (m_netClient) through which we send all the
game states to the server, which are then broadcast to all the players in the room.
import jig.gsrc.client.GNetClientObjectFactory;
protected override function initNetClient():void {
var factory:GNetClientObjectFactory;
factory = new GNetClientObjectFactory();
m_netClient = new GameClient(factory, this);
}
 
Search WWH ::




Custom Search