爲了獲得正確數量的玩家連接,請確保正確設置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];
}
}
感謝您花時間回覆我的問題。然而,一切都按照你所說的完成,並且我得到了這種行爲。其他想法? – 2012-07-12 04:12:22
如果你完成了上述所有操作,並且100%確定,請按照以下步驟操作:1-刪除應用程序,2-退出遊戲中心,3-清理生成文件夾,4-重新啓動設備,5-創建一個在應用程序內部使用AlertView的新沙箱帳號,6-交叉手指。 **注意:**切勿在iOS模擬器上測試它。 – Mazyod 2012-07-12 12:17:35
因此,如果我只有一個設備,我無法在模擬器和設備之間進行測試?如果是這樣的話,它真的很糟糕。 – 2012-07-12 15:33:12