gpt4 book ai didi

ios - GKMatchmaker 自定义媒人 View Controller 已取消

转载 作者:行者123 更新时间:2023-11-29 13:16:23 24 4
gpt4 key购买 nike

我正在实现一个自定义匹配器 View Controller ,并使用 GKMatchmaker 以编程方式为两个玩家找到匹配项:

[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *thisMatch, NSError *error)

我的自定义 Matchmaker View Controller 有一个按钮,允许玩家通过 [[GKMatchmaker sharedMatchmaker] cancel] 取消比赛。

当 Player 1 取消比赛时,有时 GKMatch 已经与 Player 2 创建。我如何通知 Player 2 Player 1 已取消比赛并开始搜索另一场比赛?

我想答案可能在于 GKMatchmakerViewController 类和调用委托(delegate)方法 matchmakerViewControllerWasCancelled 之前的代码。有谁知道我怎样才能得到这个?

最佳答案

在玩这个之后,我意识到当玩家在创建 GKMatch 之后但在玩家连接之前取消比赛时,以下函数中的 GKPlayerStateDisconnected 需要很长时间才能被调用:

- (void)match:(GKMatch *)theMatch player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state

如果 GKMatch 已创建但玩家未连接,我会在约 15 秒后再次调用 findMatchForRequest 函数来解决此问题。

有兴趣知道人们是否有更优雅的解决方案。

关于ios - GKMatchmaker 自定义媒人 View Controller 已取消,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15701561/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com