将Google API集成到libgdx项目中 [英] Integrating Google API into libgdx project

查看:85
本文介绍了将Google API集成到libgdx项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从这个问题中遵循了Aryan的建议 LibGDX和GoogleApiClient设置/integration(首次),但似乎无法使其正常工作.

I have followed Aryan's suggestion from this question LibGDX and the GoogleApiClient setup/integration (first time) but can't seem to get it to work.

我创建了ActionResolver并将其与GameHelpListener一起实现到我的AndroidLauncher中,但是这一行 gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES); 给我一个错误,说不能将GameHelper应用于此(AndroidLauncher)...任何帮助,将不胜感激.

I created the ActionResolver and implemented it into my AndroidLauncher along with GameHelpListener, but the line gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES); gives me an error, saying that GameHelper cannot be applied to this(AndroidLauncher)... I have been struggling with this for days now and can't seem to get anywhere. Any help would be appreciated.

这是我的AndroidLauncher代码

This is my AndroidLauncher code

public class AndroidLauncher extends AndroidApplication implements AdHandler, GameHelper.GameHelperListener, ActionResolver {

//一些代码

@Override
protected void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

//更多代码

    if (gameHelper == null) {
        gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
        gameHelper.enableDebugLog(true);
    }
    gameHelper.setup(this);

//更多代码

}

我的主类扩展了游戏,因此我假设此代码需要在AndroidLauncher中.我对此有误吗?

My main class extends game, so I am assuming that this code needs to be in AndroidLauncher. Am I wrong about this?

谢谢

推荐答案

使用旧版Google Play服务的上述问题中的问题链接" .

以前,我们将BaseGameUtils实用程序模块用于排行榜和成就. (play service version <11.6.2)

Previously we're using BaseGameUtils utility module for Leaderboard and Achievement. (play service version <11.6.2)

在最新版本的google play game service中,不需要BaseGameUtils.将以下依赖项注入您的android模块中,并遵循以下

In latest version of google play game service, BaseGameUtils not required. Inject below dependency in your android module and follow this thread.

implementation "com.google.android.gms:play-services-games:${gms_library_version}"
implementation "com.google.android.gms:play-services-auth:${gms_library_version}"

这篇关于将Google API集成到libgdx项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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