gpt4 book ai didi

android - 来自谷歌服务的实时多人游戏的问题(在你的房间配置中添加一个独占位掩码)

转载 作者:行者123 更新时间:2023-11-29 15:46:03 25 4
gpt4 key购买 nike

所以,我正在写基于谷歌服务的实时多人游戏(Real-time Multiplayer)。我想为自动匹配标准添加不同的角色。在谷歌文档中它看起来像这样:

If your game has multiple player roles (such as farmer, archer, and wizard) and you want to restrict auto-matched games to one player of each role, add an exclusive bitmask to your room configuration. When auto-matching with this option, players will only be considered for a match when the logical AND of their exclusive bit masks is equal to 0. The following example shows how to use the bit mask to perform auto matching with three exclusive roles:

在这个例子中,我们将等待 2 个具有专属角色的随机对手。

private static final long ROLE_FARMER = 0x1; // 001 in binary
private static final long ROLE_ARCHER = 0x2; // 010 in binary
private static final long ROLE_WIZARD = 0x4; // 100 in binary

private void startQuickGame(long role) {
// auto-match with two random auto-match opponents of different roles
Bundle am = RoomConfig.createAutoMatchCriteria(2, 2, role);

// build the room config
RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder();
roomConfigBuilder.setAutoMatchCriteria(am);

// create room, etc.
// ...
}

当我将独占角色替换为 0 时,它工作正常。但如果我为每个对手添加一些位掩码,例如 0x1,它就不起作用。玩家不连接到房间。我用实时多人游戏的谷歌示例测试了这个问题:https://github.com/playgameservices/android-basic-samples/tree/master/BasicSamples/ButtonClicker它也不起作用。你能帮我解决这个问题吗?我无法解决它。

最佳答案

所以,我解决了我的问题。如果您想将玩家与特定选项联系起来。你需要使用roomConfigBuilder.setVariant(0x4);

关于android - 来自谷歌服务的实时多人游戏的问题(在你的房间配置中添加一个独占位掩码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33196662/

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