将libgdx添加到Android本机应用程序 [英] Adding libgdx to an Android Native Application

查看:221
本文介绍了将libgdx添加到Android本机应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的儿童应用程序,可以教授我正在开发的颜色,数字等内容。它使用了我会考虑的标准的android java编程(Single Xml / java class)。我还有一个简单的游戏,恐龙使用libgdx跳过字母。

I have a simple kids app which teaches things such as colors, numbers, etc... which I am currently developing. It uses what I would consider "standard android java programming (Single Xml/java class)." I also have a simple game with a Dinosaur that jumps over letters using libgdx.

我的问题是,我希望将游戏作为整体应用程序的一部分。我想知道是否甚至可以将libgdx游戏添加到Android本机应用程序中。我尝试将相应的文件添加到我的应用程序中,但是这会导致编译错误,是否有人能指出我可以在这个问题上找到帮助的地方,或者让我知道我想要做什么甚至是可能的?谢谢。

My question is, I would like to have the game as part of the "overall" app. I would like to know if it is even possible to add a libgdx game to an android native application. I tried adding the appropriate files to my app, but this caused a compile error, could someone point me to a place where I could find help on this issue, or perhaps let me know if what I am wanting to do is even possible? Thanks.

---为了确认,我的主应用程序有一个菜单,可以带你去参加活动。我希望libgdx游戏成为其中一项活动。

---To clairify, my main app has a menu which takes you to activities. I would like the libgdx game to be one of the activities.

---编辑回复---我使用Gradle进行编译,错误多于我可以计算的错误。我已经从应用程序中删除了libgdx游戏,所以我不确定具体的错误,但是iirc有超过100个,其中很多都是R问题,我本可以弄清楚,但我找不到任何东西所以或网站上说甚至可以将libgdx添加到非libgdx应用程序。

---Edit to response---I compile using Gradle and have more errors than I can count. I've since removed the libgdx game from the app so I am not sure of specific errors, but iirc there were over 100, many of which were R issues, which I could have figured out, but I couldn't find anything on either S.O. or the web saying it was even possible to add libgdx to a non-libgdx app.

推荐答案

您可以将您的应用程序与您的应用程序集成libgdx游戏。

AndroidLauncher.java 是你的libgdx活动,你可以使用Intent从一个活动转移到另一个活动。

You can integrate your App with your libgdx game.
AndroidLauncher.java is your libgdx Activity and you can move from one activity to another using Intent.

intent = new Intent(this, AndroidLauncher.class);
startActivity(intent);

从libgdx移动 AndroidLauncher.java ,你需要从核心项目类中调用它。您需要使用界面。

and movement from libgdx AndroidLauncher.java, you need to call it from inside the core project classes. You need to use an interface.

https://github.com/libgdx/libgdx/wiki/Interfacing-with-platform-specific-code

如果您的游戏是您的应用程序的子视图。
AndroidApplication类(扩展活动)有一个名为 initializeForView(ApplicationListener,AndroidApplicationConfiguration)的方法将返回您可以添加到您的布局的视图。

If your game is sub view of your App.
The AndroidApplication class (which extends activity) has a method named initializeForView(ApplicationListener, AndroidApplicationConfiguration) that will return a View you can add to your layout.

优点。 -Code已经有了,只需要集成。

缺点 - 您需要维护OpenGL Context Loss。 Libgdx为你做。

Pros.-Code is already you have,only you need to integrate.
Cons.-you need to maintain OpenGL Context Loss. Libgdx do for you.

这篇关于将libgdx添加到Android本机应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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