Game Development Reference
In-Depth Information
The following items are displayed for each avatar:
• The avatar display picture
• Score
• Make or break friend button
• Game host sprite, in case the avatar is one
The subclass of PlayerDisplay may override the drawMe method to provide the
custom look and feel.
The constructor also sets up mouse handlers for choosing a private chat and for
making or breaking a friend relationship.
The following shows an update method, which is called whenever the client receives
an update for the avatar that is being displayed by this instance:
public function update():void {
if ( m_score != null ) {
m_score.text = "Score: " + m_av.getScore();
}
if ( m_avDisplay )
return;
updateMakeFriend();
if ( isGameHost() )
addGameHost();
else
removeGameHost();
}
The update method first updates the score field if the instance is not being displayed
for the player. The method also updates the make friend-related sprites and finally
checks if the game host sprite needs updating.
The updateMakeFriend method checks if the avatar of this instance could be made
friends with and updates the make friend button.
private function updateMakeFriend():void {
// Add add friend icon/button,
// if not friend already and not myself
if ( canMakeFriend() ) {
// not self and not a friend, yet.
if ( m_makeFriend == null ) {
m_makeFriend = Skinner.getAdd();
new ButtonEffect(m_makeFriend);
m_makeFriend.x = 70; m_makeFriend.y = 60;
 
Search WWH ::




Custom Search