简体   繁体   English

Google服务中的实时多人游戏的问题(向您的房间配置添加独家位掩码)

[英]The issue with real-time multiplayer from google services (adding an exclusive bitmask to your room configuration)

So, I am writing real-time multiplayer it based on Google Services (Real-time Multiplayer). 因此,我正在基于Google Services(实时多人游戏)编写实时多人游戏。 And I want to add different roles for automatch criteria. 我想为自动匹配条件添加不同的角色。 In the google documentation it look like this: 在google文档中,它看起来像这样:

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: 当使用此选项进行自动匹配时,仅当其专用位掩码的逻辑与等于0时,才考虑对战球员。以下示例说明如何使用位掩码对三个专用角色执行自动匹配:

In this example we will wait 2 random opponents with an exclusive role. 在此示例中,我们将等待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.
        // ...
    }

When I replace an exlusive role to 0 it works fine. 当我将专属角色替换为0时,它可以正常工作。 But if I add some bit mask, such as 0x1 for each opponent it dosen't works. 但是,如果我为每个对手添加一些位掩码(例如0x1),则该掩码无效。 Players don't connect to the room. 玩家不连接到房间。 I tested this issue with google sample for Real-time multiplayer: https://github.com/playgameservices/android-basic-samples/tree/master/BasicSamples/ButtonClicker It doesn't work too. 我使用Google示例针对实时多人游戏测试了此问题: https : //github.com/playgameservices/android-basic-samples/tree/master/BasicSamples/ButtonClicker也无法正常工作。 Could you help me with this problem? 您能帮我解决这个问题吗? I can not solve it. 我无法解决。

So, I solve my problem. 所以,我解决了我的问题。 If you want to connect players with specific options. 如果要使用特定选项连接播放器。 You need to use roomConfigBuilder.setVariant(0x4); 您需要使用roomConfigBuilder.setVariant(0x4);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在实时多人Google Play游戏服务中创建房间时向其他参与者发送数据 - How to send data to other participant on Room creation in Real-time Multiplayer Google Play Game Services 房间配置在android的Google实时多人游戏服务中无法正常运行 - Room Configuration did not work properly in google real time multiplayer services for android Android上的Google实时多人游戏 - Google Real-time Multiplayer on Android 如何检测客户是否故意在Google Play游戏实时多人游戏中留下房间? - How to detect if client intentionally left Room in Google Play Games Real-time Multiplayer? 实时多人房创造进度达到20% - Real-Time Multiplayer Room Creation progress stuck at 20% 当应用程序进入后台时,实时多人游戏Google Play游戏服务同行会断开连接 - Real-time Multiplayer Google Play Games Services peer gets disconnected when app goes in background 如何在使用Google Play游戏服务的实时多人游戏中使用僵尸玩家? - How can I use bot players in real-time multiplayer games using Google Play game services? Google Play服务实时多人游戏室创建无法正常进行 - Google Play Services real time multiplayer room creation doesn't work Google Play游戏服务实时多人游戏室错误STATUS_OPERATION_IN_FLIGHT - Google Play Game Services Real Time Multiplayer Room Error STATUS_OPERATION_IN_FLIGHT Google Play服务实时多人消息 - Google Play Services Real Time Multiplayer Message
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM