Search code examples
javaandroidgoogle-apigoogle-play-servicesmultiplayer

How to make starting player wait to take turn second in turn based multiplayer


I am creating an app that implements google's turn based multiplayer api, but I am relatively new to android. What I need to happen is when the user starts a match with an opponent, they need to wait for the second user to begin in order to have certain data passed to them before the layout can be populated. Basically what I have is what you get from google's turn based multiplayer example. It starts a match and lets the person that started the match take the first turn. Does anyone have any experience with this? I don't know how to make the starting player wait until the other player takes their turn.

I have the starting player pass their info for their layout in a byte array which the opponent will get so they can act on that layout as needed. Then the opponent will alter the byte array with their own info for the byte array. After that, then the player that started the match should be able to proceed with their turn.

Any help will be great. Thanks guys.


Solution

  • As Ogen said, calling takeTurn() made it so the starting player was not able to take their turn until the second player did.