-
Notifications
You must be signed in to change notification settings - Fork 137
Android Development Guide
The build instructions have moved. Torque2D now uses a single CMake-based build for every platform.
See Building from Source for the current Android build — the engine is compiled as
libtorque2d.sothrough Gradle → CMake (NDK), targeting arm64-v8a, fromengine/compilers/android-studio(./gradlew assembleDebug). The previous Eclipse /ndk-build/Android.mkworkflow is obsolete and has been removed.
Yes! As of the 4.0 CMake migration, the engine builds, boots, and runs on a real Android device (verified on a Pixel 7 Pro, Android 13, via Firebase Test Lab). The editor starts up, OpenGL ES comes alive, all the editor modules load, and the Project Manager renders with real text — no crashes. A few stylized heading fonts are still blank (see the Fonts note below), but the engine itself is up and running.
If you hit a crash on your own device, grab a logcat and filter on the tag Torque2D — that's where the engine prints its own startup messages, which makes it much easier to see how far boot got.
These are platform-specific behaviors to keep in mind when building a game for Android (they are about running on Android, not about compiling the engine):
-
Back button:
main.csdefines anandroidBackButtoncallback (one parameter: true/false for button down/up). By default it quits Torque when pressed; override it to suit your game. -
Splash screen: the splash is a Java dialog that must be dismissed from script. Call
hideSplashScreen()when your game has finished loading. -
Fonts: Android can get glyphs three ways — from a desktop-generated
.uftcache that ships with your game, from the device's own system fonts (these vary by device and Android version), and from your own TrueType (.ttf) files dropped intoassets/fonts. On-device lookup is by partial name: asking for"Roboto"matches the first device (or bundled) font whose embedded name contains "Roboto". Roboto is the modern Android system font (the old "Droid" family is long gone — if you have an old guide or profile asking for"Droid", change it to"Roboto"), and Torque2D also bundlesRoboto-Regular.ttfinassets/fontsso it's always there even on a stripped-down device. CalldumpFontList()to print every font the engine found to logcat — handy if a face isn't showing up.-
Heads-up — a font's name has to be readable. Torque reads the font's name out of the
.ttfto match it. Modern fonts (including Roboto) store that name in the Windows record format; the engine was recently fixed to read it (it used to only read the old Macintosh format, which left the font list empty and crashed the editor on Android). If you're on an older build and text won't load, that's why — update the engine. -
A few decorative heading fonts may render blank. If a font has no baked
.uftcache and isn't a real installed/bundled.ttf(the editor's stylized"black ops one"titles are the usual culprit), Android currently can't synthesize it and that text just won't appear. Your normal UI text (Roboto) is unaffected. Bundling the matching.ttfinassets/fonts, or pre-baking a.uft, makes it render.
-
Heads-up — a font's name has to be readable. Torque reads the font's name out of the
-
Lifecycle callbacks: Android delivers three platform callbacks in addition to
androidBackButton—onAndroidResignActive(app sent to background),onAndroidBecomeActive(app regains focus), andonAndroidWillTerminate(fired before the generalonExit, before shutdown). The engine does not auto-pause audio when backgrounded; script that yourself.