2017-02-22 61 views
0

我在objective-c中创建了一个游戏应用程序,它使用Google Play Game services作为realtimeMultiplayer功能。在应用程序中,用户必须在开始游戏之前下注一些硬币,并且我们希望连接的用户必须为相同数字的硬币下注。 我遵循文档https://developers.google.com/games/services/ios/realtimeMultiplayer。该应用程序在寻找实时玩家时没有特殊角色,例如具有不同硬币的玩家。谷歌玩具有不同角色的实时多人游戏

- (void)createQuickStartRoom { 
    GPGMultiplayerConfig *config = [[GPGMultiplayerConfig alloc] init]; 
    // Could also include variants or exclusive bitmasks here 
    config.minAutoMatchingPlayers = totalPlayers - 1; 
    config.maxAutoMatchingPlayers = totalPlayers - 1; 

    // Show waiting room UI 
    [[GPGLauncherController sharedInstance] presentRealTimeWaitingRoomWithConfig:config]; 
} 

但是我想搜索具有相同角色的玩家,就像每个玩家在我的应用中花费相同数量的硬币一样。

static uint64_t const ROLE_COIN_10 = 0x1; // 001 in binary 
static uint64_t const ROLE_COIN_20 = 0x2; // 010 in binary 
static uint64_t const ROLE_COIN_50 = 0x4; // 100 in binary 

- (void)createQuickStartRoomWithRole:(uint64_t)role { 
    GPGMultiplayerConfig *config = [[GPGMultiplayerConfig alloc] init]; 

    // auto-match with two random auto-match opponents of different roles 
    config.minAutoMatchingPlayers = 2; 
    config.maxAutoMatchingPlayers = 2; 
    config.exclusiveBitMask = role; 

    // create room, etc. 
    // … 
} 

但是没有找到所需的玩家具有相同的角色。它仍然提供具有不同角色的RealTime Player。 请让我知道,如何实现这个功能。 谢谢。

回答

2

您想使用variant字段来匹配请求相同(非零)值的玩家。在你的例子中,将变体设置为硬币的数量。独占位掩码用于匹配不同的类型。例如,如果你需要一个“进攻”和“防守”的比赛。

+0

嗨克莱顿,谢谢。它的工作非常完美。你救了我的一天:)。 –

+0

你能帮我在这个http://stackoverflow.com/questions/42427673/invite-friend-in-google-play-services –

相关问题