Skip to main content

FlixelAndroidLauncher

View source

class

org.flixelgdx.backend.android.FlixelAndroidLauncher

public class FlixelAndroidLauncher

Launches the Android version of the FlixelGDX game.

The developer creates a subclass of FlixelGame and an Android launcher activity that extends AndroidApplication. In onCreate, create the game instance and call FlixelAndroidLauncher.launch(FlixelGame, AndroidApplication).

Constructors

FlixelAndroidLauncher()

public FlixelAndroidLauncher()

Methods

launch(FlixelGame, AndroidApplication)

public static void launch(FlixelGame game, AndroidApplication activity)

Launches the Android version of the game in RELEASE mode.

Parameters:

NameDescription
gameThe game instance to launch.
activityThe Android application activity.

launch(FlixelGame, AndroidApplication, FlixelRuntimeMode)

public static void launch(FlixelGame game, AndroidApplication activity, FlixelRuntimeMode runtimeMode)

Launches the Android version of the game with the given runtime mode.

Call this from the onCreate method of your AndroidApplication activity. Create your FlixelGame subclass instance and pass it here along with the activity (typically this).

Parameters:

NameDescription
gameThe game instance to launch (e.g. new MyGame(...)).
activityThe Android application activity (must extend AndroidApplication).
runtimeModeThe FlixelRuntimeMode for this session (TEST, DEBUG, or RELEASE).

launch(FlixelGame, AndroidApplication, FlixelRuntimeMode, Runnable)

public static void launch(FlixelGame game, AndroidApplication activity, FlixelRuntimeMode runtimeMode, Runnable onBeforeInitialize)

Launches the Android version of the game with an optional pre-initialization callback.

onBeforeInitialize fires after all default FlixelGDX backend services (alerter, audio, etc.) have been registered but before Flixel.initialize is called. Use it to override any of those defaults without needing to duplicate the rest of the launcher wiring:

public class MyAndroidLauncher extends AndroidApplication {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FlixelAndroidLauncher.launch(
new MyGame("My Game", 800, 600, new InitialState()),
this,
FlixelRuntimeMode.RELEASE,
() -> Flixel.alerter = myCustomAlerter
);
}
}

Parameters:

NameDescription
gameThe game instance to launch (e.g. new MyGame(...)).
activityThe Android application activity (must extend AndroidApplication).
runtimeModeThe FlixelRuntimeMode for this session (TEST, DEBUG, or RELEASE).
onBeforeInitializeOptional callback invoked just before Flixel.initialize. Pass null to skip.