我在 iOS 游戏中心创建了一款回合制游戏, 游戏运行良好,数据在玩家之间正确传递。
我想知道:
你怎么能排除一个先于另一个输了的玩家?
我在任何地方都找不到引用资料 我该怎么走?
提前致谢,抱歉我的英语不好
安杰洛
编辑:
好的,我试过了,成功了(被排除的玩家也可以查看比赛)
//When current player is excluded
GKTurnBasedMatch *currentMatch = [[GCTurnBasedMatchHelper sharedInstance] currentMatch];
currentMatch.currentParticipant.matchOutcome == GKTurnBasedMatchOutcomeQuit
//FOR SEND TURN :
NSUInteger currentIndex = [currentMatch.participants indexOfObject:currentMatch.currentParticipant];
GKTurnBasedParticipant *nextParticipant;
NSUInteger nextIndex = (currentIndex + 1) % [currentMatch.participants count];
nextParticipant = [currentMatch.participants objectAtIndex:nextIndex];
for (int i = 0; i < [currentMatch.participants count]; i++) {
nextParticipant = [currentMatch.participants objectAtIndex:((currentIndex + 1 + i) % [currentMatch.participants count ])];
if (nextParticipant.matchOutcome != GKTurnBasedMatchOutcomeQuit) {
///prossimo giocatore che NON è stato escluso
break;
} else {
/////Prossimo giocatore perché questo è stato escluso
}
}
[currentMatch endTurnWithNextParticipant:nextParticipant matchData:data completionHandler:^(NSError *error) {
[…]
}];
最佳答案
我不是 Game Center 专家,但根据内存,您的代码可以选择下一个回合的人。因此,您可以计算出谁将在下一回合进行比赛,并简单地跳过任何已经输掉的玩家。不过,您可能应该更新他们的游戏数据,以便他们可以玩到最后。
Ray Wenderlich 有几个关于 Game Center 回合制游戏的示例教程:Beginning turn-based gaming with iOS 5
没有要分享的示例代码 - 抱歉。
关于ios - 如何在 iOS Game Center TURN-BASED App 中排除输了的玩家,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11246706/