how multiple player can join the game with only two players in a single room.

0 votes
i am using appWarp j2me sdk.

i am developuing two player fighting game. if two players have join the room and at that time third player want to play the game he can not enter into the game although one player left the game. he has to reexecute the game.

i want to do in my game that when there is only player try to play game he has to creat room then join that room. when other player try to play game he will get the join room option other than create room option.

and naw third player try to play game he will not able to enter into the room because there are already  two players in that room. so third player will get the option to create new room.

when fourth player try to play the game he will get the join room option ctreated by third player or if any player of first room left the room then fourth player can join any of these two room.

your sample of code is not working in this way so plz give me advice to do so.....i want to do. In this way no of players can play my game.
asked Apr 19, 2014 in AppWarp by maheshsahu125 (20 points)

1 Answer

0 votes
Hi,

This is a common scenario. Following is the way to go about it.

Call JoinRoomInRange(1,1,true)

This will attempt to join a room with one player inside it.

If its successful, great - you are done.

If its unsuccessful, then the client should create a new room for 2 players and join it. So

createRoom("", "", 2);

The response is in the zonerequestlistener

onCreateRoomDone()

You will get the room id in this - you can then join this room (newly created) using joinRoom(roomId) and wait for the next player to come.

So in your example - player 1 will create a room (joinRoomInRange will fail for it as no room exists), join it and wait. player 2 will join that room (joinRoomInRange is success).

player 3 will create a room (joinRoomInRange will fail as no room with 1 player exists), join it and wait.

player 4 will join that room (joinRoomInRange is success).
answered Apr 19, 2014 by dhruvc (1,099 points)
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
...