我在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 Centre 回合制游戏的示例教程:使用 iOS 5 开始回合制游戏
没有示例代码可以共享 - 抱歉。