我有一场回合制比赛,有两名参与者,A 和B。现在轮到 A 了。 B 通过调用退出:
[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit ... etc.
就 A 的 Game Center 应用程序而言,与 B 的比赛仍在进行中 – 比赛状态为 GKTurnBasedMatchStatusOpen
,匹配结果分别为GKTurnBasedMatchOutcomeNone
和GKTurnBasedMatchOutcomeQuit
。
从文档中可以看出,参与者 A 应该检测到这一点并调用:
participantA.matchOutcome = GKTurnBasedMatchOutcomeWon;
participantB.matchOutcome = GKTurnBasedMatchOutcomeQuit;
[self endMatchInTurnWithMatchData: ... etc.
但是,似乎没有针对 participantQuitOutOfTurnWithOutcome
的通知,并且周期性地遍历每场比赛以结束回合感觉就像是一场困惑。
结束这些比赛的正确方法是什么?
最佳答案
它有一个很好的解决方案:)
首先你设置一个处理程序
[GKTurnBasedEventHandler sharedTurnBasedEventHandler].delegate = self;
之后,你会得到回调
handleInviteFromGameCenter: handleTurnEventForMatch:didBecomeActive: handleMatchEnded: handleTurnEventForMatch:didBecomeActive: handleTurnEventForMatch:didBecomeActive: player:receivedExchangeRequest:forMatch: player:receivedExchangeCancellation:forMatch: player:receivedExchangeReplies:forCompletedExchange:forMatch:
你需要这个方法
handleMatchEnded:
处理对方的比赛结束。
关于ios - 在 Game Center 中正确响应远程玩家退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23746271/