我正在使用Android Play Games - Real Time Multiplayer
我的应用程序.当我创建一个新房间时,回调onRoomCreated()
返回STATUS_NETWORK_ERROR_NO_DATA
5%的时间.我不知道为什么我偶然发现这个错误.
某些帖子建议应在创建新帖子之前关闭.我总是在super.onstop()
打电话之前离开我的房间.我也在onLeftRoom()
创建一个新房间之前等待回调.
堆栈跟踪
02-20 22:57:07.208: I/libjingle(1763): Token type:OAuth2
02-20 22:57:07.208: I/libjingle(1763): Final XMPP server hostname talk.google.com port to 5222
02-20 22:57:07.316: I/libjingle(1763): OpenSSLAdapter::OnConnectEvent
02-20 22:57:07.416: I/libjingle(1763): BeginSSL: talk.google.com
02-20 22:57:07.476: W/libjingle(1763): Warning(openssladapter.cc:388): ContinueSSL -- error -1
02-20 22:57:07.480: W/libjingle(1763): Warning(openssladapter.cc:397): OpenSSLAdapter::Error(ContinueSSL, -1)
02-20 22:57:07.504: I/libjingle(1763): SSL Cleanup
02-20 22:57:07.532: I/libjingle(1763): Token type:OAuth2
02-20 22:57:07.532: I/libjingle(1763): Final XMPP server hostname talk.google.com port to 5222
02-20 …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个实时多人游戏.游戏本身运作良好.我正在努力与房间配置.我使用谷歌玩游戏作为框架.游戏概念是为单个房间管理从2到7的玩家数量.这场比赛是一场棋盘游戏.因此,如果连接很多玩家,那就更好了.否则游戏会很无聊.我有可能使用谷歌AutoMatchCriteria进行配对:
final int MIN_OPPONENTS = 1, MAX_OPPONENTS = 6;
Bundle autoMatchCriteria = RoomConfig
.createAutoMatchCriteria(MIN_OPPONENTS, MAX_OPPONENTS, 0);
RoomConfig.Builder rtmConfigBuilder = RoomConfig.builder(this);
....
Run Code Online (Sandbox Code Playgroud)
如果我设置MIN_OPPONENTS = 1并且MAX_OPPONENTS = 6,那么在大多数情况下,游戏将以2名玩家开始.在SO-Thread中,谷歌开发者提到:
自动匹配算法不会非常努力地最大化匹配中的玩家数量......
我也可以使用MIN_OPPONENTS = 6和MAX_OPPONENTS = 6.通过此设置,只有7个玩家连接到房间时才会启动游戏.我的游戏提供了许多游戏变体和很多难度级别.因此我假设并不总是有7名球员可用.我需要一个灵活的解决方案,始终保证游戏开始.
同一个谷歌人使用计时器描述了一个解决方案:SO-Thread
我不知道从这个概念开始.我应该在哪里启动计时器?有没有人成功实现这个概念?如果这个人可以分享一些代码片段或者向我提供一些进一步的解释,那将是非常好的.其他建议也是受欢迎的.
更新2019年:仍在寻找改进.请给出提示.
我的gradle文件包含:
implementation 'com.google.android.gms:play-services-appstate:6.5.87'
implementation 'com.google.android.gms:play-services-games:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-ads:16.0.0'
Run Code Online (Sandbox Code Playgroud)
这就是我开始多人游戏的方式:
void startQuickGame() {
final int MAX_OPPONENTS = 6;
int min_opponents = 1;
Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(min_opponents,
MAX_OPPONENTS, 0);
RoomConfig.Builder rtmConfigBuilder = RoomConfig.builder(this);
rtmConfigBuilder.setMessageReceivedListener(this);
rtmConfigBuilder.setRoomStatusUpdateListener(this);
rtmConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
rtmConfigBuilder.setVariant(variant);
switchToScreen(R.id.mpGamescreen_wait);
keepScreenOn();
Games.RealTimeMultiplayer.create(mGoogleApiClient, rtmConfigBuilder.build());
} …
Run Code Online (Sandbox Code Playgroud) android real-time multiplayer google-play-services google-play-games
我想将仪表板的时间范围永久设置为 1 天。不幸的是,在刷新浏览器时它会跳回到 3 小时。此外,每个仪表板都应该有自己的时间范围。例如,默认情况下,仪表板 1 应该有 1 天的时间范围,仪表板 2 应该有 1 个月的时间范围。我怎样才能做到这一点?
我使用appcompat v7(23.1.1)获得MaterialDesign向后兼容性.在API 21设备上,它看起来不错.在较旧的API版本中,我的样式没有任何影响.为什么?
这是我的style.xml里面的values文件夹:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<!-- customize the color palette -->
<item name="android:colorPrimary">@color/teal200</item>
<item name="android:colorPrimaryDark">@color/teal500</item>
<item name="android:colorAccent">@color/material_green_A200</item>
<item name="android:statusBarColor">@color/teal500</item>
<item name="android:navigationBarColor">@color/teal500</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:colorButtonNormal">@color/button</item>
<item name="colorControlNormal">@color/deeporange300</item>
<item name="colorControlActivated">@color/deeporange500</item>
<item …
Run Code Online (Sandbox Code Playgroud)