Android - Google Play Services realtime multiplayer - Automatching and waiting room bugs

吃可爱长大的小学妹 提交于 2019-12-19 21:53:59

问题


I'm doing a multiplayer realtime implementation, using the google play services. The goal is to have 4 players playing together in a room, but if there are not enought players at a time, the game should be started with only 2 or 3 players. Ideally with a timer asking the first players to wait a little.

Solution 1 : I use RoomConfig.createAutoMatchCriteria(1, 3, 0); But in that case, the automatching never tries to connect 3 or 4 players, but always starts games with only 2 players (onRoomConnected() called with 2 players joined and no one else can then join the room)

Solution 2 : I use RoomConfig.createAutoMatchCriteria(3, 3, 0); It works fine with 4 players. But i can't start the game "manually" with 2 or 3 players as no Callback is called, especially the method onPeersConnected() is never called with 2 or 3 players online but only when 4 players are connected (and by the way, the waiting room is useless because we can't see the 2 other players waiting with us, and when the 3rd is connected, we sudendly see all the 3 other players and receive all the corresponding Callbacks).

I tried to set Games.RealTimeMultiplayer.getWaitingRoomIntent(mGoogleApiClient, room, 2); But (as the documentation says it should be possible with at least 2 players) a button to start the game without waiting the missing players is never shown (it only says : "not enought players to start"). [Edit : it seems it's normal it only works with invitations, not automatch.]

So i'm stuck in my implementation for my idea...

it works fine with always 2 players (createAutoMatchCriteria(1, 1, 0).

it works fine with always 4 players (createAutoMatchCriteria(3, 3, 0), except we can't see if other players are waiting with us in the waiting room.

Thanks for your help!

来源:https://stackoverflow.com/questions/34112241/android-google-play-services-realtime-multiplayer-automatching-and-waiting-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!