, , . , . Android APK .
, android core build.gradle. :
project(":core") {
apply plugin: "java"
apply plugin: "android"
configurations { natives }
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
}
}
, , , , , . , , TaskSets, Android. - :
public interface PlatformResolver {
public void handleTasks();
}
-
public class MyGame extends ApplicationAdapter {
PlatformResolver platformResolver;
public MyGame (PlatformResolver platformResolver){
this.platformResolver = platformResolver;
}
public void render(){
if (shouldHandleTasks) platformResolver.handleTasks();
}
-
public class AndroidLauncher extends AndroidApplication implements PlatformResolver {
public void handleTasks(){
}
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
someDataType SomeData;
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new MyGame(this), config);
}
}
-
public class DesktopLauncher implements PlatformResolver{
public void handleTasks(){
Gdx.app.log("Desktop", "Would handle tasks now.");
}
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = "My GDX Game";
config.width = 480;
config.height = 800;
new LwjglApplication(new MyGame(this), config);
}
}