如何从android后端调用核心方法? [英] How to call core method from android backend?
问题描述
我可以使用GDX(平台特定代码)中的android方法,但是可以从android后端获取libgdx方法吗? 我有Firebase数据库.在游戏的android方面,我捕获了数据库中的所有更改.而且我需要将这些更改转移到我的核心后端(例如,更新一些参与者,标签等).最好的方法是什么?
I can use android methods from GDX (Platform specific code), but is it possible to get libgdx method from android back-end? I have firebase database. On android side of my game I catch any changes in database. And I need to transfer that changes to my core back-end (For example update some actors, labels, and so on). What's the best way to do that?
推荐答案
可以使用 core-module
是所有平台的通用部分,因此您可以访问项目中的任何位置.
core-module
is common part of all platform so you can access anywhere in your project.
请保留ApplicationListener
的引用,如果要call any method
/ access data member
您的核心模块.
Keep reference of ApplicationListener
, If you want to call any method
/access data member
of your core module.
内部android模块:
Inside android module :
public class AndroidLauncher extends AndroidApplication {
MyGdxGame gdxGame;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
gdxGame=new MyGdxGame();
initialize(gdxGame, config);
}
public void andoridMethod(){
System.out.println(gdxGame.x); //access data member
gdxGame.doSomething(); //access method
}
}
内部核心模块:
public class MyGdxGame implements ApplicationListener {
public int x=4;
public void doSomething(){}
// Life cycle methods of ApplicationListener
}
这篇关于如何从android后端调用核心方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!