To set up android, run
lime setup android after installing HaxeFlixel. You can choose to download necessary components (eg. Android SDK and NDK) or use existing installations.
The Haxe compiler uses its
cpp target to compile your
Haxe code for the LibSDL OpenGL library so that the Android NDK can then use this "native-code" for your Android game. You can read more about the Android NDK from Google here, however this process is completely automated by OpenFL. Android is part of the cpp group of targets and when developers mention
cpp the topic may be relevant to HaxeFlixel Android.
With OpenFL using native-code and OpenGL with LibSDL, the rendering methods are different to where Flixel started with Flash. Android uses GPU accelerated Texture Batching for the best possible performance on mobile devices.
//your android code //your android code //your android code
Project XML settings
Mobile platforms can use a window width and height of 0, which is a special value that uses the full resolution of the current display.
<window width="0" height="0" background="#FFFFFF" fps="60" />
OpenFL also exposes the following specific settings for the Android target:
<android target-sdk-version="17" /> <window hardware="true" allow-shaders="true" require-shaders="true" if="cpp"/> <window vsync="true" antialiasing="4" if="cpp" /> <window orientation="portrait" /> || <window orientation="landscape" if="cpp"/>
Custom PNG icons: (Check Iconography / Android Developers for more info)
<icon path="36.png" size="36" if="android" /> <icon path="48.png" size="48" if="android" /> <icon path="72.png" size="72" if="android" /> <icon path="96.png" size="96" if="android" />
Sublime Text, Flash Develop and IntelliJ Idea support Android compilation through their GUI.
The basic command to compile and test Android:
lime test android
Run this command from the root folder of your project; the default project.xml will be used automatically. For the test command to run on your device you should have it connected with ADB working correctly.
If you want to use the Android simulator, add
-simulator when running/testing. Be sure your virtual device is API >=15 and has GPU enabled.
lime test android -simulator