I have some questions that just weren't answered in the documentation: https://developers.google.com/games/services/android/multiplayer

  1. RoomConfig.createAutoMatchCriteria(1, 3, 0) does not work as intended. It will only try to match up a 2 player game, never a 3 and never a 4. I have only 3 devices, but I spent perhaps 2 hours attempting to match up the devices and they were only done in pairs. I read this post: Auto Match Criteria in Google Multiplayer Sample BittonClicker Game for android which had similar issues. Also GamesClient.getSelectPlayersIntent(1, 3) has the same bug.

  2. GamesClient.getRealTimeWaitingRoomIntent(room, 0) does not work as intended. The documentation states " If the number of connected participants is more than or equal to the specified minimum to start the game, the Start Playing option in the waiting room UI is enabled." however upon testing I have yet to see a 'Start Playing' option. What happens is that the waiting room is exited automatically whenever the first person is connected after a message saying 'Prepare to Play' pops up. Changing from 0 to 1 has the same effect, so does changing to Integer.MAX_VALUE. Can anyone provide a way to achieve the intended functionality? Am I doing something wrong here?

  3. I have played a few multiplayer games on android which have users join, then leave, and someone else takes their place. I have been unable to see this in testing, no matter what parameters I assume for automatching. If a player leaves a room, will another player come and fill his place? If so, will `Room.getParticipantIds().size() return a number greater than 4?

  4. In some of these games, once a game has started no one else joins. I have tested these games and not found on one occasion that I have joined a room and been told that it is in progress. Are they somehow telling the server that the game has started and not to match them up with other players? How are other players only joining games that have not started yet? (These games are using Google Play Game Services)

I have other questions but I don't want to ask unnecessary questions. These questions would be so helpful and would reduce my stress greatly if answered.

Thank you for your time.

有帮助吗?

解决方案

1) This is working exactly as Google intends. There is NO GUARANTEE that if you use createAutoMatchCriteria(1, 3, 0) that 3 opponents will be found for your game. In my testing, (4 devices requesting at once) 90% or more of the time It will become 2 games of 2 that get started. Only if I have one device invite either a friend or manually select AutoPick, then the chances go up dramatically of getting a 3 or 4 player game started (otherwise, pure AutoMatch results in the 2 and 2 behavior)

2) If I understand the behavior correctly, you get one player that leaves the waiting room (normally the device that initiates first) and then the other player joins, but the first player leaves the Waiting Room, and the other is left in it? If so, then you need to ensure you use the following ( I do it in onRoomConnected

try {
        bWaitRoomDismissedFromCode = true;
        finishActivity(RC_WAITING_ROOM);
    } catch (Exception e) {
        dLog("would have errored out in waiting room");
    }

This will then close the waiting room for any players that are in the waiting room still, and get them back into your activity. From below, if you want the behavior of "Start Playing", this is only if there are invited players that have accepted invitations into the room. (IF Google meant it to work another way for AutoMatch, they haven't got it there yet)

public Intent getRealTimeWaitingRoomIntent (Room room, int minParticipantsToStart)

Returns an intent that will display a "waiting room" screen that shows the progress of participants joining a real-time multiplayer room. Note that this must be invoked with startActivityForResult(Intent, int), so that the identity of the calling package can be established.

If the necessary number of peers have connected and it's now OK to start the game, or if the user explicitly asked to start the game now, the activity result will be RESULT_OK. If the user bailed out of the waiting room screen without taking any action, the result will be RESULT_CANCELED. If the user explicitly chose to leave the room, the result will be RESULT_LEFT_ROOM.

Regardless of what the result code was, the waiting room activity will return a data intent containing a Room object in EXTRA_ROOM that represents the current state of the Room that you originally passed as a parameter here.

If desired, the waiting room can allow the user to start playing the game even before the room is fully connected. This is controlled by the minParticipantsToStart parameter: if at least that many participants (including the current player) are connected to the room, a "Start playing" menu item will become enabled in the waiting room UI. Setting minParticipantsToStart to 0 means that "Start playing" will always be available, and a value of MAX_VALUE will disable the item completely. Note: if you do allow the user to start early, you'll need to handle that situation by explicitly telling the other connected peers that the game is now starting; see the developer documentation for more details.

Finally, note that the waiting room itself will never explicitly take any action to change the state of the room or its participants. So if the activity result is RESULT_LEFT_ROOM, it's the caller's responsibility to actually leave the room. Or if the result is RESULT_CANCELED, it's the responsibility of the caller to double-check the current state of the Room and decide whether to start the game, keep waiting, or do something else. But note that while the waiting room is active, the state of the Room will change as participants accept or decline invitations, and the number of participants may even change as auto-match players get added.

3) Google Play Game Services (for Auto-Match) does NOT have this behavior. Only when all participants for a Room are found and selected by the server, will the room actually be Connected (onRoomCreated does NOT mean that a ROOM for communication has been setup, it is for the players to join if they are waiting for others to join... and can be switched once the Service has all the other Players) onRoomConnected is the last call to all connected players and signifies the Room is ready for passing messages around. Now, if you have intivees, the behavior changes, in that yes, you can see an invitee accept, but if they then leave the room.. there is NO WAY to have it filled by an AutoMatch, but you CAN see them leave... (how nice eh?)

4)If the games are using GPGS, then once a room has been created and made it to the onRoomConnected stage, it is being played and no more matches can be done with that room. So when you join a room, everyone else has joined at the same time. So when a player leaves, nobody else will be able to join.

public abstract void onRoomConnected (int statusCode, Room room)

Called when all the participants in a real-time room are fully connected. This gets called once all invitations are accepted and any necessary automatching has been completed. Possible status codes include:

STATUS_OK if data was successfully loaded and is up-to-date. STATUS_CLIENT_RECONNECT_REQUIRED if the client needs to reconnect to the service to access this data. STATUS_INTERNAL_ERROR if an unexpected error occurred in the service. Parameters room The fully connected room object. The room can be null if it could not be loaded successfully.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top