我与两位参赛者进行回合制比赛, A 和 B 。目前它已经 A 了。 B 通过致电:
退出[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit ... etc.
就 A 的游戏中心应用而言,与 B 的匹配仍在进行中 - 匹配状态为GKTurnBasedMatchStatusOpen
,并且匹配结果分别为GKTurnBasedMatchOutcomeNone
和GKTurnBasedMatchOutcomeQuit
。
从文档中可以看出参与者 A 应该检测到这一点并致电:
participantA.matchOutcome = GKTurnBasedMatchOutcomeWon;
participantB.matchOutcome = GKTurnBasedMatchOutcomeQuit;
[self endMatchInTurnWithMatchData: ... etc.
然而,似乎没有participantQuitOutOfTurnWithOutcome
的通知,并且定期迭代每场比赛以结束转弯感觉就像一个kludge。
结束这些比赛的正确方法是什么?
答案 0 :(得分:11)
它有一个很好的解决方案:)
首先设置处理程序
[GKTurnBasedEventHandler sharedTurnBasedEventHandler].delegate = self;
之后,您将获得回调
handleInviteFromGameCenter: handleTurnEventForMatch:didBecomeActive: handleMatchEnded: handleTurnEventForMatch:didBecomeActive: handleTurnEventForMatch:didBecomeActive: player:receivedExchangeRequest:forMatch: player:receivedExchangeCancellation:forMatch: player:receivedExchangeReplies:forCompletedExchange:forMatch:
你需要这个方法
handleMatchEnded:
处理对手方的比赛结束。