gpt4 book ai didi

ios - 游戏中心 : Player Groups

转载 作者:行者123 更新时间:2023-11-28 15:02:53 26 4
gpt4 key购买 nike

我正在为 iOS 开发一款游戏。我需要开始过滤比赛,以便人们正确配对。我正在阅读有关玩家属性和玩家组的信息,并且由于我的游戏的性质,PlayerGroups 是必经之路。
正如我在 Apple 文档中阅读的那样,他们提供了这个示例:

GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 4;
request.playerGroup = MyMap_Forest | MyRulesCaptureTheFlag;

现在,我完全确定缺少某些部分,但我的主要问题是:
什么是 | (垂直线)。玩家组是数组吗?或者它是什么?阅读他们的文档,它说它是一个无符号的 32 位整数,如何将其转换为由垂直线分隔的 2 个不同值?
此外,Apple 表示:

A constant for each is chosen and the two are bitwise ORed together to create a unique number for the player group. Game Center only searches for other players with the same map and group combination.

这很含糊,我不确定是我做的常数还是他们做的还是谁做的?而且我不确定最后是否有 typO,它们的意思是 map 和 rules 而不是 map 和 group(举个例子)。此外,如果它们是 OR'ed,则匹配将是森林 map 中的 EITHER 或捕获公寓,但不是两者,如果设置这些参数,我假设你需要两者。

无论如何,有没有人知道更多这方面的信息并能为我提供更好的示例或更好地解释如何使用 PlayerGroups?谢谢!

最佳答案

apple 说的是组可以是Bit field .只有对组具有相同值的玩家才会匹配在一起。

至于为什么要用OR运算符,只是一般用于位域。从技术上讲,您可以在那里使用 +

假设示例中的开发人员决定将最低有效字节用于 map ,将次低字节用于游戏模式,那么该组将是:

   MyMap_Forest          00000000 00000000 00000000 00001001
OR MyRulesCaptureTheFlag 00000000 00000000 00000011 00000000
------------------------------------------------------------
00000000 00000000 00000011 00001001

可以看到结果中包含了使用哪个 map 和玩哪种模式的信息。

关于ios - 游戏中心 : Player Groups,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48743257/

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