Adding libgdx to an Android Native Application

二次信任 提交于 2019-12-01 21:43:42

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);

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

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.

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

bbb8989

In Libgdx your entire game is just a single Activity. You can start it as any other activity from your code. Please follow Can I run an Activity before running libgdx? for details.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!