谷歌玩游戏服务与多人活动切换 [英] Google Play Game Services multiplayer with Activity switching

查看:211
本文介绍了谷歌玩游戏服务与多人活动切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid游戏中我有一个回合制多人。用户等待对手在大堂每当正好3相匹配,他们去到一个新的游戏厅一起,这是另一种活动比大堂。

In my Android game I have a turn-based multiplayer. Users wait for opponents in the lobby and whenever exactly 3 are matched, they go to a new game room together, which is another Activity than the lobby.

该文档建议让活动扩展BaseGameActivity。但是当我切换了活动,而玩家已经连接,don'I需要将连接部件的服务而我的活动,然后结合?

The docs suggest to let the Activities extend BaseGameActivity. But as I switch the Activity while players are already connected, don'I need to place the connectivity parts in a Service which my Activity then binds to?

有没有人已经尝试与游戏服务?如何开始,如果我不能用BaseGameActivity?

Has anyone tried already with Game Services? How to begin if I can't use BaseGameActivity?

推荐答案

所以,其中一个原因,我们写的所有谷歌玩游戏服务的样品为单活动游戏是因为活动之间的切换需要您从GamesClient断开并连接的新的活动一个新的。

So, one of the reasons we wrote all the Google Play game services samples as single-Activity games is because switching between Activities require you to disconnect from the GamesClient and connect a new one from the new Activity.

因此​​,使用碎片可能是去最简单的方法。它也pretty的清洁,可以让你,如果你想通过结合他们做平板电脑的布局。

So using Fragments is probably the easiest way to go about this. It's also pretty clean and allows you to make a tablet layout by combining them if you want to.

在特定的,如果你正在建立一个多人游戏,断开将断开的房间,所以你不能启动握手后切换到不同的活动: - )

In particular, if you are setting up a multiplayer game, disconnecting will disconnect you from the room, so you can't switch to a different Activity after starting the handshake :-)

这篇关于谷歌玩游戏服务与多人活动切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆