Game Development Reference
In-Depth Information
}
m_sprite.addChild(m_makeFriend);
m_makeFriend.addEventListener(MouseEvent.CLICK,
makeFriend);
}
else {
// For a new friend made,
// remove the make friend
// is exists
if ( m_makeFriend != null &&
m_sprite.contains(m_makeFriend) )
m_sprite.removeChild(m_makeFriend);
}
}
/**
*
* @return returns false for self and if already a friend
*
*/
protected function canMakeFriend():Boolean {
var gc:GameClient;
gc = PulseGame.getInstance().getGameClient();
return ( (gc.getMyAvatar().getId() != m_av.getId()) &&
!gc.isFriend(m_av.getId()) );
}
As we will see in the next chapter, if the game host leaves the room, the server picks
another player at random to be the game room host. The following methods take
care of any such game room host updates:
/**
* Checks if the avatar is a game host
*
* @return true if avatar is the game room host
*
*/
protected function isGameHost():Boolean {
var gc:GameClient;
gc = PulseGame.getInstance().getGameClient();
if ( gc.getMyGameRoom() != null )
return (gc.getMyGameRoom().getHostId() == m_av.getId());
else
return false;
}
 
Search WWH ::




Custom Search