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?
Accessing Platform Specific API inside core module
can be possible using Interfacing.
core-module
is common part of all platform so you can access anywhere in your project.
Keep reference of ApplicationListener
, If you want to call any method
/access data member
of your core module.
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
}
}
Inside core module :
public class MyGdxGame implements ApplicationListener {
public int x=4;
public void doSomething(){}
// Life cycle methods of ApplicationListener
}