2017-02-22 100 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 –

相關問題