2013-12-09 47 views
1

我在使用Game Center製作一個簡單的多人遊戲。我正在使用Apple的代碼。我剛換的最大玩家數量的5而不是2:我可以在GameCenter遊戲中擁有超過4名玩家嗎?

- (void)hostMatch:(id)sender 
{ 
GKMatchRequest *request = [[GKMatchRequest alloc] init]; 
request.minPlayers = 2; 
request.maxPlayers = 5; 

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

[self presentViewController:mmvc animated:YES completion:nil]; 
} 

當我有request.maxPlayers 2-4等於它工作正常,但一旦我去了5它給了我這個錯誤:

The requested operation could not be completed because the match request is invalid.

有沒有人想出瞭解決方案?

回答

3

這一切都取決於您正在創建的遊戲類型。下表是從蘋果的文檔的:

Table 7-3

Maximum number of players for each kind of match

Match Type. Maximum Number of Players

Peer-to-Peer 4

Hosted. 16

Turn-based. 16

這裏是鏈接進一步研究:https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/GameKit_Guide/MatchmakingwithGameCenter/MatchmakingwithGameCenter.html#//apple_ref/doc/uid/TP40008304-CH12-SW7

+0

我願做一個託管的遊戲。我看到有一個GKTurnBasedMatch.h可以用來代替GKMatch.h,但我還沒有發現任何託管匹配。你知道我可以做一個託管比賽嗎? – KKendall

+0

這可能爲時已晚,但GKMatchmakerViewController具有託管屬性,如果將其設置爲YES,則它將成爲託管匹配 – Andrew