Game Development Reference
In-Depth Information
The recipient will receive the chat message and is notified via the
onReceivedChat callback.
function onReceivedChat(msg:String, senderId:int,sender:String):void;
Chatting in Hello World
Here again we did not write any specific code to handle chat. For those who are
curious, one may take a look at the Chat class to see what happens when a player
types in a message and hits enter as well as the PulseGame class to see what
happens when a chat message is received from the server.
Customizing chat display
The class that handles chat is called Chat . The Chat class is part of the Outline
class. The Chat class includes both input handling, where it sends the player's chat
message to the server for further broadcast, and receiving chat messages from the
server and displaying it in the history textbox.
To supply our own subclass of Chat, we may first subclass from the Chat class and
then override the Outline class.
The following shows the containment and subclassing for providing our own
subclass of Chat:
We first create our subclasses of Outline ( MyOutline ) and Chat ( MyChat ). We then
need to override the initOutline method in the subclass of PulseGame ( MyGame )
as follows:
protected override function
initOutline(avatar:GameAvatarClient):void {
m_outline = new MyOutline(avatar);
}
 
Search WWH ::




Custom Search