NME is an impressive crossplatform technology particularly appropriate for 2D games development. And by crossplatform that mean:
- Windows/Mac/Linux and iOS/Android/webOS – at full, native, C++/OpenGl speed,
- and Flash so you can also compile it for the browser.
Activity & contributions around the NME project has increased a lot recently and it seems to have become mature enough as a few companies have started using it to develop (fairly impressive casual) commercial games. If you have an iPhone I warmly recommend trying Ponon Deluxe (free) – it’s incredibly slick and a clever variation on the Tetris theme.
If you know Flash and AS3…
…you’ll be up and running in a few hours:
- this is most feature complete implementation of the Flash API that you will get your hands on – more complete than what Starling will ever be, and more complete than the subset of AIR you can use to keep performance decent,
- development is in haxe, a clever language with increasing IDE support that you can however code like AS3 90% of the time.
It’s hard emphasize enough about how incredible NME performance is. That’s really close to hand written C++ but with Flash’s easy to use APIs and a similar, strongly typed, language.
The native back-end is based on SDL, a robust and powerful opensource crossplatform C++ library used in hundreds of games & applications.
NME is composed of 2 parts:
- a thin crossplatform API layer written in haxe,
- precompiled C++ libraries for each native target.
Haxe code isn’t executed by a VM: it’s transformed into regular C++ code and then compiled & linked with the target library. The haxe-to-C++ transformation is extremely fast and the C++ compilation is just as efficient as with regular C++ code: initial compilation is long, iterations reasonably quick.
And if it’s not fast enough, you can rely on haxe’s lightning fast Flash compilation and, in FlashDevelop, use the regular Flash interactive debugger with your haxe code.
I know you love numbers, here’s one very sweet table with numbers 😉
This is a modified BunnyMark, as popularized by Iain Lobb.
To get the best of NME when animating a lot of elements you’ll want to use Graphics.drawTiles, which is a C++ specific addition over the Flash API to allow high performance batch rendering of images using a spritesheet. This drawTiles method now lets you animate position, rotation, scale, alpha and color of the items, at a crazy speed. Also these results are with image smoothing enabled.
Is that test relevant? Obviously you’ll have to reduce greatly the number of bunnies as soon as you’ll start making the scene more complex.
Edit #1: added more numbers and a nice, tiled grass, background to the bunnies. And a pirate.
Edit #2: New iPad
The benchmark was adapted to auto-scale accordingly to iOS retina (or not): everything looks the same size as on a non-retina device. It was tested in retina and non-retina resolutions.
New iPad is definitely a much more powerful device than iPad 2 (and the most powerful device ever at this time). However the conclusion will surprise you: New iPad, with its extra resolution, should practically be considered a less powerful device than iPad 2. Slightly disappointing obviously in a way, as iPhone 4, even with retina resolution, proved to be as (if not more) powerful than the 3GS at 4x the pixels count.
Bonus conclusion: haxe NME works just fine in the crazy 2048×1536 resolution 🙂 Make sure you get the iOS5.1 SDK (yes it works in Snow Leopard) and set the deployment target to 5.1 in xcode.
|iPhone 3G||500||N/A*||480×320||Outdated, but it works 🙂|
|LG Optimus One||1000||N/A*||480×320|
|SE Xperia X8||1000||N/A*||480×320|
|SE Xperia Mini Pro||1750||4500||480×320|
|iPhone 3GS / iPod Touch 3||2750||1000||480×320|
|Nexus One / HTC Desire||1500||N/A*||800×480|
|iPod Touch 4||3250||1000||960×640||Much weaker than iPhone 4|
|HTC Desire S/HD||4000||1500||800×480|
|iPhone 4 / iPod Touch 4.5||4750||1750||960×640|
|Samsung Galaxy S 2||7500||3500||800×480|
|iPhone 4S||10000||4750||960×640||This phone is a monster|
|Samsung Galaxy Tab||2000||1000||1024×600|
|Samsung Galaxy Tab 10.1||4000||1500*||1280×800||Overclocked at 1.4GHz|
|Advent Vega||4250||2000*||1024×600||Tegra2 dual 1Ghz|
|Acer Iconia A501||3500||1000||1280×800|
|TouchPad webOS||8000||2000**||1024×768||Overclocked at 1.5GHz (safe)|
|New iPad (retina)||5250||2250||2048×1536|
|New iPad (low res)||11500||4250||1024×768|
* Framerate can’t reliably get close to 60fps on many Android devices (45fps max on the Nexus One).
** Framerate is never at stable 60fps but a few fps unders.
Want to try on your Android device? I love more numbers too 😉
- Download the APK or an IPA for jailbroken iDevices
- Tap on the FPS indicator to toggle between 30 and 60 fps.
- Tap on the Bunnies indicator to add 250 bunnies.
What about the desktop?
Flash / HTML5
NME naturally targets Flash which is great for quick iterations and a great debugging experience in FlashDevelop, however the drawTiles feature is pretty specific to native targets. A Flash implementation is coming, based on the classical Graphics.drawTriangles, but it will hardly be as powerful and complete as the native version. For heavy performance needs you’ll want to use a different rendering path (like blitting) for the Flash target – haxelibs like gm2d are meant to abstract these differences.
Currently Jeash, the HTML5 backend for NME, doesn’t support drawTriangles at all, so no drawTiles here.
Try the Flash BunnyMark.
It turns out that the BunnyMark runs just great on the desktop using the respective native C++ targets. On my 2 years old MacBook 13″ and its lousy CPU & GPU I have 15k bunnies bouncing at 60fps, and on my PC (similar CPU, better GPU) I’m at 20k bunnies, no sweating.
Time to get your hands on the code and play with NME?