Improvements Around the Corner for NME

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.

www.haxenme.org

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.

  • Great stuff Joshua, really excited about the developments. Any idea when some of those features you mentioned that are on the repo will hit haxelib?

  • it’s so cool that nme grows so fast o/

    good job =)

  • Excellent, and thankyou all so much for the work on NME.

  • Wahyudinata

    I cant wait to see these awesome improvements to come out! Any ETA? I am already using NME for our game development!

  • aaulia

    Nice one Joshua, is there any plan to support feature like the JNI for Android but instead for iOS (I mean call iOS API from haXe) ? Also, is there any news from Phillipe or Nicolas about the FlashDevelop integration ? That would complete the whole tool chain 😀

  • There are a few things that should be finalized before the next release, but I think it would be great to share some of these improvements soon. I apologize that I don’t have an exact timeline, but I hope it won’t be long

  • Philippe is awesome. A lot of ideas for improving code completion or developing the project have come from our conversations. Supporting the nme.* package, for example, will benefit code completion in FD4, and though FlashDevelop does not officially support editing for the NMML project format, there is a project template on the “Get Started” page at haxenme.org that makes it easy to make new FlashDevelop projects for NME

  • Marco

    Is it possible to compile HaXe NME to AS3? When we will use nme.* it won’t be possible?

  • With the upcoming version of NME, you will still be able to compile for Flash. If you use “nme.display.Sprite”, it will automatically remap to “flash.display.Sprite” when publishing for Flash.