ios – GKTurnBasedMatch退出

ios – GKTurnBasedMatch退出,第1张

概述当用户使用GameKit在iOS应用程序中基于回合制匹配“轮流”退出时,委托方法 – (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController playerQuitForMatch:(GKTurnBasedMatch *)匹配;在GKTurnBasedMatchmake 当用户使用GameKit在iOS应用程序中基于回合制匹配“轮流”退出时,委托方法 – (voID)turnBasedMatchmakerVIEwController:(GKTurnBasedMatchmakerVIEwController *)vIEwController playerQuitForMatch:(GKTurnBasedMatch *)匹配;在GKTurnBasedMatchmakerVIEwController上调用,根据文档,我们应该为当前玩家设置结果,并调用participantQuitInTurnWithOutcome:nextParticipant:matchData:completionHandler:

但是,我无法找到关于球员退出的任何信息.那是在轮到我的时候,我退出了媒人视图控制器.似乎没有任何委托方法,并且令人惊讶的是,通过调试我的应用程序,我发现转弯被发送(即使它现在不在我的回合中).

任何人都可以解释行为和正确的方法来处理退出退出.

解决方法 您可以在中处理此方案

-(voID)handleTurnEventForMatch:(GKTurnBasedMatch *)match

循环参与者,如果触发播放器是本地播放器,并且他的结果是“退出”,并且他不是当前参与者(在另一个地方处理–turnBasedMatchmakerVIEwController:playerQuitForMatch :),那么继续并退出游戏转.

for (int i = 0; i < [match.participants count]; i++) {                GKTurnBasedParticipant *p = [match.participants objectAtIndex:i];    if ([p.playerID isEqualToString:[GKLocalPlayer localPlayer].playerID])    {        // Found player        if (p.matchOutcome == GKTurnBasedMatchOutcomeQuit)        {            // Player Quit... ignore current participants and end out of turn only for the other player            if (![match.currentParticipant.playerID isEqualToString:p.playerID])            {                // not the current participant and he quit                [match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:nil];                 break;            }                       }    }}
总结

以上是内存溢出为你收集整理的ios – GKTurnBasedMatch退出全部内容,希望文章能够帮你解决ios – GKTurnBasedMatch退出所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/999433.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存