2012-07-12 68 views

回答

0

为了获得正确数量的玩家连接,请确保正确设置GKMatchRequest

在这个例子中,我有一个游戏,只有当有两名球员连接工作,所以我设定的最小&最大玩家数为2:

GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; 
request.minPlayers = 2; 
request.maxPlayers = 2; 

GKMatchmakerViewController* mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease]; 
mmvc.matchmakerDelegate = self; 

然后,一切你注意到按预期工作。


编辑:

再次阅读您的问题之后,还要确保您已保留给你的GKMatch对象:

-(void) matchmakerViewController:(GKMatchmakerViewController*)viewController didFindMatch:(GKMatch*)match;

当然,你有设置此匹配对象的代表:

//Done! 
-(void) matchmakerViewController:(GKMatchmakerViewController*)viewController didFindMatch:(GKMatch*)match{ 
    [self dismissModalViewController]; 
    [self setCurrentMatch:match]; 

    match.delegate = self; 

    if (!matchStarted && match.expectedPlayerCount == 0){ 
     matchStarted = YES; 
     [delegate onMatchStart]; 
     self.handlerVoice = [OnlineHandlerVoice handlerWithMatch:currentMatch]; 
    } 
} 
+0

感谢您花时间回复我的问题。然而,一切都按照你所说的完成,并且我得到了这种行为。其他想法? – 2012-07-12 04:12:22

+0

如果你完成了上述所有操作,并且100%确定,请按照以下步骤操作:1-删除应用程序,2-退出游戏中心,3-清理生成文件夹,4-重新启动设备,5-创建一个在应用程序内部使用AlertView的新沙箱帐号,6-交叉手指。 **注意:**切勿在iOS模拟器上测试它。 – Mazyod 2012-07-12 12:17:35

+0

因此,如果我只有一个设备,我无法在模拟器和设备之间进行测试?如果是这样的话,它真的很糟糕。 – 2012-07-12 15:33:12

相关问题