Game Development Reference
In-Depth Information
The same PlayerDisplay class is used in multiple places for drawing a player's own
avatar, in a friend's panel, and in the other player's panel in the game screen.
Let's walk though some of the code for PlayerDisplay in the PulseUI framework.
The PlayerDisplay class is a subclass of the Sprite class and adds the
following variables:
public class PlayerDisplay extends Sprite
{
// The corresponding avatar object
public var m_av:GameAvatarClient;
// A sprite that holds all the child sprites
private var m_sprite:Sprite;
// for score display
private var m_score:TextField;
// Special case to display the self
private var m_avDisplay:Boolean;
// Display sprite of a game host
private var m_gameHost:Sprite;
// If host sprite is displayed
private var m_hostDisplayed:Boolean;
// Make friend sprite button
private var m_makeFriend:Sprite;
// Avatar Display picture
private var m_pixSprite:Sprite = null;
}
The constructor is shown below:
public function PlayerDisplay(av:GameAvatarClient,
avDisplay:Boolean = false)
{
m_av = av;
m_avDisplay = avDisplay;
drawMe();
}
The constructor takes in two parameters: av , which is the avatar object that the sprite
is representing, and avDisplay , a Boolean value that should be passed in true if the
instance is created to display the player himself or herself.
The drawMe function does all the work of creating and placing the child sprites
within the PlayerDisplay sprite.
 
Search WWH ::




Custom Search