2

我到处搜索,没有找到解决这个问题的方法:

我有一个 2 人游戏,回合制,通过游戏中心。

玩家完成移动后,他可以在 Game Center 中退出游戏。在我的情况下,这自动意味着游戏已经结束并且其他玩家赢了。但是,我找不到实现此目的的 Game Center 方法。

我不能使用 endMatchInTurnWithMatchData 因为它不是这个玩家轮到的。

如果我在轮到其他玩家时尝试使用 endMatchInTurnWithMatchData,这也是不可能的,因为没有其他玩家可以将 endMatchInTurnWithMatchData 发送给(因为其他玩家已经退出)。

有没有人知道这个问题的解决方案?

谢谢,马丁

4

2 回答 2

0

你必须实现turnBasedMatchmakerViewController:playerQuitForMatch:的方法GKTurnBasedMatchmakerViewControllerDelegate。这是一个示例代码:

-(void)turnBasedMatchmakerViewController: (GKTurnBasedMatchmakerViewController *)viewController playerQuitForMatch:(GKTurnBasedMatch *)match {
    NSUInteger currentIndex = [match.participants indexOfObject:match.currentParticipant];
    GKTurnBasedParticipant *next = [match.participants objectAtIndex:(currentIndex + 1)%[match.participants count]];
    [match participantQuitInTurnWithOutcome:GKTurnBasedMatchOutcomeQuit nextParticipants:@[next] turnTimeout:MAXFLOAT matchData:match.matchData completionHandler:nil];
    [next setMatchOutcome:GKTurnBasedMatchOutcomeWon];
    [match endMatchInTurnWithMatchData:match.matchData completionHandler:nil];
}
于 2013-07-05T10:21:58.397 回答
0

我在同样的问题上苦苦挣扎。最终对我有用的是在调用参与者QuitInTurnWithOutcome 时将自己设置为下一个参与者。

希望能帮助到你!

于 2014-06-24T05:20:31.283 回答