ios - GKTurnBasedMatch 参与者QuitOutOfTurnWithOutcome

标签 ios game-center

我正在开发一款回合制 Game Kit 游戏。我正在为玩家参与的比赛制作自定义用户界面。我使用

loadMatchesWithCompletionHandler:

有一个用例,用户正在进行一场比赛,还没轮到他们,他们想退出,不再在游戏列表中看到那场比赛。我的代码调用

participantQuitOutOfTurnWithOutcome:withCompletionHandler: 

并从 TableView 中删除该行。

此时另一位玩家轮到,看到他们的对手已经退出

match.remoteParticipant.matchOutcome == GKTurnBasedMatchOutcomeQuit

所以他们通过调用

来结束游戏
endMatchInTurnWithMatchData:completionHandler:

问题是该游戏仍然存在于 Game Center 中。所以调用

loadMatchesWithCompletionHandler: 

在第一个玩家的应用程序上会将其拉回并显示在游戏表中。

我能想到的唯一解决方案是从表中保存匹配的匹配ID和黑名单。看起来有点笨拙。

似乎没有用于此的 API。即退出并删除匹配我的匹配列表。是否有更好的方法仅使用 Game Center API 来处理这种情况?

最佳答案

我认为您需要先将每个参与者的 matchOutcome 属性设置为 GKTurnBasedMatchOutcomeNone 以外的其他属性,然后才能删除匹配。来自文档:

Calling this method ends the match for all players. This method may only be called by the >current participant. Before your game calls this method, the matchOutcome property on each >participant object stored in the participants property must have been set to a value other >than GKTurnBasedMatchOutcomeNone.

关于ios - GKTurnBasedMatch 参与者QuitOutOfTurnWithOutcome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16951694/

相关文章:

ios - 使用 Firebase 的内存泄漏

ios - 无法快速弹出警报

ios - findMatch 与具有不同游戏模式的 iOS GameCenter

带有游戏中心的 iPhone 应用程序

ios - 如何让按钮阴影与 Swift 4.2 一起使用?

ios - 当应用程序处于后台且静音模式打开时需要播放声音

ios - 从 GameCenter 发送和接收数据 : Swift

ios - 游戏中心 iOS 7 不工作

ios - viewWithTag 和 addSubview

ios - 在 Game Center 回合制比赛中结束一个回合。