It has been exciting to be a part of NME as it has grown the past few weeks. Three weeks ago, NME 3.0.0 was released on haxelib, making it possible to use the new install tool process without using Subversion.
If you haven’t heard of the install tool already, it makes cross-platform development this easy:
haxelib run nme test MyProject.nmml cpp haxelib run nme test MyProject.nmml cpp -64 haxelib run nme test MyProject.nmml webos haxelib run nme update MyProject.nmml ios haxelib run nme test MyProject.nmml android haxelib run nme test MyProject.nmml flash
Rather than forcing a single runtime on multiple platforms, NME uses Haxe and the standard toolchain for each platform to compile games and applications natively for each target. Using the same codebase, this makes it possible to publish projects that are adapted and optimized for each system.
I’ve been helping Hugh with some improvements to NME for the next release. While these are still under development, and may change, I am excited to share some of the feature and workflow improvements that are coming around the corner.
1.) Install tool build/run/test supported for iOS
If you already work with NME, or noticed in my command sample above, you probably know that iOS has been using the “update” command instead of the “test” command like other targets. When you prompt the install tool to “test”, it runs “update”, “build” and “run” in succession.
Unlike other targets, NME has not supported “build” and “run” for iOS. Running the “update” command generates an XCode project, which you then can use to publish to the device of your choice. This is much easier than many of the alternatives, but it still could be better.
The latest versions of NME will (and do, on the repository) support “build” for iOS, as well as “run” and “test” if you are targeting the simulator. To my knowledge, it is necessary to use XCode if you wish to push code to a device (without jail-breaking), but this still should really help for use with the simulator. Though they may change before the next release, here are the supported commands:
haxelib run nme build MyProject.nmml ios haxelib run nme test MyProject.nmml ios -simulator haxelib run nme test MyProject.nmml ios -simulator -ipad
You can also add “-debug” if you would like to use the Debug configuration instead of Release.
2.) SharedObject support for all platforms
A while ago, NME gained support for flash.net.SharedObject, which makes it easy to save or load settings in persistent storage. At the time, support was added for Android and iOS, but other platforms did not support the API. The latest builds of NME implement SharedObject for all targets, increasing the utility of the API. Currently, data will be stored in a “sharedobjects” folder in the same directory of your application. This may change in the future, or may improve to use the “AppData” and “Application Support” user directories on Windows and Mac, but for now you should be able to use it without having to write your own File I/O code.
3.) Embedded fonts made easier
In the current development builds, ApplicationMain.getAsset will return a Font object for all platforms, making it simple to use embedded fonts:
var font = ApplicationMain.getAsset ("assets/MyCustomFont.ttf"); var format = new TextFormat (font.fontName, 24, 0xFF0000); var text = new TextField (); text.defaultTextFormat = format; text.width = 240; text.height = 60; text.embedFonts = true; text.text = "Hello World"; addChild (text);
The “embedFonts” property has also been added to C++ targets. It is currently ignored, but this makes it easy to display smooth, embedded fonts on all platforms without writing conditional code. Minor improvements include support for “_sans”, “_serif” and “_typewriter” and adjustments to allow more compatibility with TTF fonts.
4.) JNI access from Haxe
Hugh has also made some incredible improvements that should make it possible to access Java functions and APIs on Android without having to leave Haxe classes. If you need to display a Toaster or access a native API, this will make it much easier to add these calls into your code. I’m sure we’ll all hear more about it once the next release is ready.
5.) Support for nme.*
Though the NME API is practically the same as Flash, some differences do remain. If you are using a code editor that provides code completion, it would be nice to see what classes are available for all targets, or to see the classes that NME supports that are not available in Flash (like nme.filesystem.File). One of the other changes that are currently on the repository make it possible to write your applications using the nme.* package namespace instead of the flash.* package namespace, if you so choose. As a result, you can reference “nme.display.Sprite” or “nme.display.BitmapData” and compile correctly to all targets.
Soon I hope to be able to leverage haxedoc to generate API documentation for the website.
There are other improvements working their way into NME, like improved support for embedded WAV sounds and device vibration (haptic feedback). If you haven’t already checked out the new website, www.haxenme.org, I invite you to take a look. There is a growing forum community, as well as showcase applications, tutorials and help to get started with the framework.