iOS - 使用GameCenter开发多人游戏?

问题描述:

我该如何实现&使用GameKit测试多人(回合制)游戏?这里是我面临的问题:iOS - 使用GameCenter开发多人游戏?

  • 没有其他匹配连接到沙箱,所以我没有从macth finder获得任何回调。
  • Xcode只允许模拟器的一个实例运行,所以如何连接两个客户端?

在测试多人GameKit游戏时,一些建议会很棒。

编辑:

我必须在设备上运行应用程序的一个实例。另一个模拟器上,我仍然无法找到匹配。

// I call this code on both clients after authentication is successful 
    GKMatchRequest *request = [[GKMatchRequest alloc] init]; 
    request.minPlayers = 2; 
    request.maxPlayers = 2; 

    [[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) { 

    if (error) 
    { 
     // Process the error. 
     NSLog(@"error"); 
    } 
    else if (match != nil) 
    { 
     self.myMatch = match; 
     match.delegate = self; 
     if (!self.matchStarted && match.expectedPlayerCount == 0) 
     { 
       self.matchStarted = YES; 
     } 
    } 
}]; 

您需要两个设备进行测试,因为模拟器没有得到任何回调。此外,如果您使用自动匹配,则在您搜索第二台设备上的自动比赛游戏之前,先给游戏中心服务器几分钟更新一次。