Game Development Reference
In-Depth Information
In order to supply our own PlayersDisplay, we first need to override the
initPlayersDisplay method in our subclass of PulseGame (MyGame). The
overriding code is as follows:
protected override function initPlayersDisplay():void {
m_playersDisplay = new MyPlayersDisplay();
}
If we want to supply our own subclass of PlayerDisplay (MyPlayerDisplay), we need
to override the createNewPlayerDisplay method as follows:
public override function
createNewPlayerDisplay(av:GameAvatarClient,
avDisplay:Boolean =
false):PlayerDisplay {
return new MyPlayerDisplay(av, avDisplay);
}
Note that we should create the MyPlayerDisplay directly, but always via the above
method. The constructor of PlayerDisplay takes in two parameters, one being the
avatar object and the a Boolean value, which in most cases is false , hence the
default value. One instance of PlayerDisplay class is also used for displaying the my
avatar icon as part of the outline. This always appears on the top left-hand corner of
the screen. In case of this instance, several things like the game host is not drawn.
Avatar-related APIs
Let us now explore some of the Pulse SDK APIs that are related to the avatar. This
includes a subset of methods on GameClient and a subset of callback methods on the
GameClientCallback interface.
PulseGame client APIs
The following API will return the player's own avatar; the returned value is valid
only upon successful login:
public function getMyAvatar():GameAvatarClient
The getPlayer method returns a player with the given ID. This method is only useful
when the avatar is inside a game room, as the game client will not have access to
other players until then.public function getPlayer(id:int):GameAvatarClient
This getAllPlayers method returns all the players within the same game room as the
player: public function getAllPlayers():Array
 
Search WWH ::




Custom Search