Jump to content

Multiplayer handling from selection screen into game itself


Recommended Posts

Hi all! 

I have been trying to untangle this issue for a while now and was wondering if anyone might have some ideas on a solution?

The basics is that I am working on a game that has a character selection screen where players choose their avatar and then enter into the board. At the moment you can select and enter immediately; there is no "lobby". This was causing an issue where players who were still on character selection get an update from socket about a player joining the board and thus would show the other players' avatars scattered on the selection screen. (Because when a player entered the board, they were triggering a new game state, not just rewriting the elements on the screen if that's helpful info).
My attempt at fixing this is/was to hide the joined players using "visibility = false" until the socket server gets a message that the new player had entered the board. But this caused an issue where a player would only ever see the subsequent players joining the board, not everyone already joined. For example, the first player who joined will see everyone who joins, but second player will see everyone but player one, third player will be everyone but first and second player, etc.

In doing some digging, I noticed that the sprites _exist_ and I can reset the sprite's visibility to true, but the other character sprites remain invisible since Phaser seems to have automatically updated some of the sprites' other properties. For example, for second player, the first player's sprite's alive property is set to false, renderable is set to false and the renderOrderID is missing entirely.

Basically, I am curious if there is a way to make sure players don't prematurely die or if maybe anyone has another idea on how to refactor to make this viable? If not, I am open to reworking this to keep the character selection and game play in the same state, rather than two separate ones with the last ditch effort of implementing a "lobby".

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...