如何实施Google Play游戏服务,Intellij,libgdx

时间:2015-01-20 14:43:07

标签: java intellij-idea libgdx

在找到一些信息后我正好在哪里:

  • BaseGameUtils文件夹位于我的根文件夹中。
  • google-play-services_lib位于我的根文件夹
  • 我的settings.gradle已修改为:include' desktop',' android',' core'," BaseGameUtils"因为我只使用桌面和Android项目
  • 将build project(":BaseGameUtils")添加到我的build.gradle中作为android依赖

我对gradle概念不熟悉,所以,此刻我有点失落。 我可以找到Intellij的任何教程,其中大部分都是针对Eclipse的。 一些帮助将非常感激=)

编辑1:

经过几个小时的测试,这就是我得到的。

使用高级选项" IDEA"导入使用Libgdx安装程序创建的项目。检查Intellij。 (当intellij启动时通过弹出窗口加载Gradle)[这真的需要吗?]

设置BaseGameUtils:

将BaseGameUtils文件夹移动到项目的根文件夹中。 将BaseGameUtils作为模块添加到项目中。 将google-play-service.jar添加到BaseGameUtils模块。

设置Android项目:

将BaseGameUtils作为模块依赖项添加到Android项目

这是我迷路的地方:

在核心项目中创建一个接口,将BaseGameActivity中的功能添加到其中。 制作Android项目的主要类" AndroidLauncher.java"实现GameServiceInterface和GameHelperListener。 添加到Android项目的主要类" AndroidLauncher.java"遗漏的方法。

2 个答案:

答案 0 :(得分:4)

libgdx wiki上有一个教程。

安装" Google Play信息库"从Android SDK管理器应该足够了。无需移动google-play-services_lib文件夹。

我在root / bulild.gradle中的android项目定义:

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile project(":libraries:BaseGameUtils")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        compile 'com.android.support:appcompat-v7:20.0.+'
        compile 'com.android.support:support-v4:20.0.+'
        compile 'com.google.android.gms:play-services:5.0+'
    }

}

答案 1 :(得分:0)

---更新---

现在有一种更简单的方法。 见下面的答案。


我花了很长时间,但我终于成功了

我为那些很难用Intellij实施Google Play游戏服务的人创建了一个小而未完成的教程

Tutorial Link

相关问题