When to start game

0 votes
Hi All

My online game start when there are two users inside room. Where is the best place to start a game? I mean when I join room, someone may be already at room, or maybe someone may join room after me. So, I should be able to see number of players than I should start game. Can you help me where to write StartGame() function? I wrote my solution below but there may be better solutions I could not think.

My solution is: When I join room or when someone joins room(onUserJoinedRoom event) I call api getLiveRoomInfo. Then I can get number of current player. Than if it is 2, I can start game.
asked Jan 5, 2016 in AppWarp by gokhan (20 points)

1 Answer

0 votes
Hello Gokhan,

The right place is onUserJoinedRoom event to start the game. What you can do is, create room with maxUser parameter value 2. So there will not be any chance of joining any third user in a room.

Whenever you get the onUserJoinedRoom event, check the user name, if it is not you then there is a second user in the room, hence you can start the game. In this way, there is no need to call getLiveRoomInfo to detect the second user.

I hope it will help.

Thanks.
answered Jan 5, 2016 by rajeev.etc (1,660 points)
onUserJoined is not executed for local player?
Start Multiplayer Game Functionality
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...