Multiplayer tutorial 2: chat room

1

Index

Taggé

Statistiques

5,252 visites, 8,812 vues

Outils

Partager

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Chat events

At the top of the event sheet are some global variables:

It is good practice to have global constants for the game name, instance name and room name if they do not change. This means there is only one place we need to update our project if we wanted to change any of them. In this case all three are always the same: everyone who uses the app joins the same chat room. If we changed any of them, the user would end up joining a different chat room. However if we wanted to make separate chat rooms it would be most sensible to put them in a different signalling room: game instances are intended for different versions of the same app, and the game name should always be the same for the same project.

Chat log group

This group simply has a function to add a new line of text to the chat log, and then scroll it to the bottom. Since we update the chat log in a lot of places, it makes sense to have a single function do this instead of repeating the actions over and over again. Also after several chat messages the content of the object could go off the bottom of the object, so we always scroll to the bottom so the latest messages are in view.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!