jni*_*nic 12 objective-c ios game-center
我有两个参与者,基于回合的比赛一个和乙.这是目前一个轮到.B通过致电退出:
[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit ... etc.
Run Code Online (Sandbox Code Playgroud)
至于一个的游戏中心的应用程序而言,与之相匹配的乙仍然在发挥作用-比赛状态GKTurnBasedMatchStatusOpen,而比赛的结果是GKTurnBasedMatchOutcomeNone和GKTurnBasedMatchOutcomeQuit分别.
从文档中可以看出,参与者A应该检测到这一点并致电:
participantA.matchOutcome = GKTurnBasedMatchOutcomeWon;
participantB.matchOutcome = GKTurnBasedMatchOutcomeQuit;
[self endMatchInTurnWithMatchData: ... etc.
Run Code Online (Sandbox Code Playgroud)
然而,似乎没有任何通知participantQuitOutOfTurnWithOutcome,并且定期迭代每场比赛以结束转弯感觉就像一个kludge.
结束这些比赛的正确方法是什么?
l0g*_*g3r 11
它有一个很好的解决方案:)
首先,你设置一个处理程序
[GKTurnBasedEventHandler sharedTurnBasedEventHandler].delegate = self;
之后,您将获得回调
handleInviteFromGameCenter: handleTurnEventForMatch:didBecomeActive: handleMatchEnded: handleTurnEventForMatch:didBecomeActive: handleTurnEventForMatch:didBecomeActive: player:receivedExchangeRequest:forMatch: player:receivedExchangeCancellation:forMatch: player:receivedExchangeReplies:forCompletedExchange:forMatch:
你需要这种方法
handleMatchEnded:
处理对手方的比赛结束.
| 归档时间: |
|
| 查看次数: |
285 次 |
| 最近记录: |