【问题标题】:Google Play Game Services client setup and connectingGoogle Play 游戏服务客户端设置和连接
【发布时间】:2013-06-06 02:37:37
【问题描述】:

我一直在使用LibGDX 框架开发游戏,现在我想通过 google play 服务设置它以使用排行榜并设置一些成就等。

第一个问题:

要使用 GamesClient 库,是否需要请求令牌或某种登录方式到 google?

第二个问题:

我已经使用调试密钥创建了我的客户端 ID,因此我可以通过 eclipse 轻松测试游戏。但我总是拒绝连接(GamesClient.connect())。我通过其 Builder 构建 GamesClient:

GamesClient.Builder gcb = new GamesClient.Builder(adView.getContext(), this, this);
                    gcb.setAccountName(accounts[0].name);
                    gcb.setViewForPopups(adView);
GamesClient gc = gcb.create();

稍后调用 gc.connect() 时,它只是调用覆盖的 onConnectionFailed();

我已将元数据添加到我的 android 清单中,如下所示:

   <application
   ....
   <meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
   ....

app_id 内容是我为游戏创建的客户端 ID 的 12 位左右。(我也尝试使用完整 ID)。

所以我认为这不是问题。

更多信息: Client ID screenshot

提前感谢您的帮助!

【问题讨论】:

    标签: android libgdx google-plus google-play-services google-play-games


    【解决方案1】:

    一切就绪!最后经过一些尝试没有结果,这里是方法(适合 libgdx 用户)。

    第一个问题的答案:根本不需要获取请求,甚至不需要使用google提供的AuthUtil类。

    第二个问题的答案:

    请务必阅读一些有关 GamesClient 及其实现的教程。

    Step1:获取谷歌提供的BaseGameUtils库,here。

    Step2:在你的MainActivity上实现GameHelper.GameHelperListenner,例如:

    public class MainActivity extends AndroidApplication implements GameHelper.GameHelperListener
    

    并声明一个将为您完成所有登录工作的 GameHelper。 (不要忘记调用它的构造函数和设置方法,更多信息请参见 GameHelper 类)。

    第 3 步:调用 beginUserInitiatedSignIn()(来自 GameHelper 实例)以启动登录流程。

    就是这样!

    建议:按照输入数字游戏教程了解登录流程(自述文件中的说明)here。

    【讨论】:

    • 谢谢!正是我想要的……(LibGdx rulez !)
    猜你喜欢
    • 2013-05-27
    • 2014-09-17
    • 2017-06-13
    • 1970-01-01
    • 2014-05-12
    • 1970-01-01
    • 2018-03-31
    • 1970-01-01
    • 2014-02-02
    相关资源
    最近更新 更多