[英]How to handle app versions in real-time multiplayer using Google Play Games?
Here is the example: 这是示例:
In this situation, I want Play Games Services to allow auto-connect for versions v1 and v2, but players on v3 should only connect to other v3. 在这种情况下,我希望Play游戏服务允许v1和v2版本的自动连接,但是v3上的玩家只能连接到其他v3。
How do I do this with Google Play Games Real-time multiplayer ? 如何使用Google Play游戏实时多人游戏做到这一点?
The RoomConfig has a variant field that is used to match players. RoomConfig的变量字段用于匹配玩家。 The variant value must exactly match in order to connect players.
变量值必须完全匹配才能连接播放器。 For more information see: https://developers.google.com/android/reference/com/google/android/gms/games/multiplayer/realtime/RoomConfig.Builder.html#setVariant(int)
有关更多信息,请参见: https : //developers.google.com/android/reference/com/google/android/gms/games/multiplayer/realtime/RoomConfig.Builder.html#setVariant(int)
When building the room your code would look something like (where GameVersion is the version of your game): 建造房间时,您的代码应类似于(其中GameVersion是游戏的版本):
int minPlayers = 2;
int maxPlayers = 2;
long bitmask = 0;
Bundle am = RoomConfig.createAutoMatchCriteria(minPlayers, maxPlayers, bitmask);
// build the room config
RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder();
roomConfigBuilder.setAutoMatchCriteria(am)
.setVariant(GameVersion < 3 ? 1 : 3);
RoomConfig roomConfig = roomConfigBuilder.build();
// create room:
Games.RealTimeMultiplayer.create(mGoogleApiClient, roomConfig);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.