Multiplayer tutorial 2: chat room

13

Index

Features on these Courses

Stats

27,072 visits, 118,746 views

Tools

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 the first two are always the same: everyone who uses the app joins the same game instance. The room name can be changed to join separate chat rooms.

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.

  • 8 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • How did you get the tab order to work on this? I see that I can tab from NameTextBox (UID 2) to RoomNameTextBox (UID 13) to JoinButton (UID 3). I can't find this anywhere and all my google searches say it can't be done, that you can only tab in order of UID, yet you did it in this project. Please help!!!

  • Hi, I tried to export the chat template to Android Debug apk and installed on my phone and try to host a room. It successfully connected and created the room as host. But when I try to connect another peer using my laptop browser it says connected as peer but will be kicked eventually. Am I missing something? Can I use multiplayer on Android device? Is the multiplayer plugin for browsers only?

  • sorry, where i can find the link to download the archive?

    • "To get going, open the Example: Multiplayer - chat room example that comes with Construct 2. This can be found in the Select template or example dialog that opens when pressing File - New."

  • When using "Self.Text & newline & Function.Param(0)"

    Construct gets an error and claims "Function is not and object". Is there any one who can help?

  • Why is Tutorial 1 under Construct 3 while Tutorial 2 jumps to Construct 2? I think you should put everything under Construct 3.