How to Create an NME Extension

One of the things that I love about NME is that it is easy to extend. Unfortunately, there is not much documentation on the subject, so I want to take a few minutes to help describe what you can do with an NME extension, and how to create one. Trust me, it is not difficult.

include.nmml

Beginning with NME 3.2, all you need to make an extension is add a file called “include.nmml.” This file is processed just like an ordinary NMML project file, with the exception that paths are relative to where your extension is located.

For example, in the “Test” extension I have created, this is my “include.nmml” file:

<?xml version="1.0" encoding="utf-8"?>
<project>
 
	<ndll name="test" />
	<java path="project/android" />
 
</project>

You could include assets, defines, haxelib dependencies, NDLL references, Java code… practically anything you can define from an ordinary NMML project file for NME, you can define using your extension. Continue reading How to Create an NME Extension

Sample Native Extension for NME

I created a native extension sample for NME this morning that I would like to share with you:

http://www.joshuagranick.com/code/haxe/NME%20Extension%20Test.zip

Have you ever wanted to access your own code, written in C, C++ or Objective-C? This sample should help illustrate the “glue” that makes it possible to write and access native code from Haxe. I’ve also added a new “extension” tag to the NMML project file format which should make the workflow even easier. Continue reading Sample Native Extension for NME

Cross-Platform Game Running in Flash *and* HTML5

I am very happy to share with you some of the first-fruits of integration between NME and Jeash — a working game!

Yesterday, I began the process of experimenting with adding an HTML5 target, thanks to Jeash. I am really impressed with how the project has developed since I last tried it out. Niel Drummond has done a great with the framework, as well as all others who have contributed to Jeash.

Similar to other targets in NME, I am publishing to Javascript using “haxelib run nme test MineHX.nmml html5”. Embedding assets as well as managing the build process is handled by the tool. I have unified Jeash with other targets, so you can still use a single API for loading embedded fonts, accessing bitmaps or playing sounds. The platform differences are being handled under the hood.

Flash

http://www.joshuagranick.com/examples/minehx/flash/

HTML5

http://www.joshuagranick.com/examples/minehx/html5/

Haxe NME Screencast Is Now Online

I have just posted a new screencast, walking through creating a new application with NME. The application compiles to Flash, Windows, Mac, Linux, webOS, iOS and Android. Starting with a blank project template, I load in bitmaps, create classes, add animations, handle key events, handle mouse events and cover some other principles that are great for understanding NME and how you can use it to create games.

http://www.joshuagranick.com/videos

The blank template I used to create this screencast is available for download, here.

Addendum

Later in the screencast, I test the application again in C++, and find that the background is not tiling like I expected. I have just tested and confirmed that setting “cacheAsBitmap” to true on the background Sprite will make it look identical in Flash and C++. You might also be able to tile graphics properly if your image follows a standard “multiples of 2” dimension.

Android, iOS, webOS (and More!) — Cross-Platform Made Easy

“…One codebase for all platforms? A dream come true.”

 – from Twitter, 19 minutes ago

Going cross-platform is getting even easier. The latest builds of NME make it possible to cross-compile to Android, iOS, webOS and Windows, right out-of-the-box. Support for Mac OS, Linux, Flash, Neko and GPH should also be re-integrated soon. This is due, in no small part, to Nicolas Cannasse, who created the Haxe language and compiler, and Hugh Sanderson, who created NME for Haxe.

Update (01/16/2012): If you would like to get started with NME, the best resource is http://www.haxenme.org/developers/get-started. There are automated installers for Windows, Mac and Linux, as well as a new “nme setup” command which simplifies the install of supporting tools for Windows, webOS, Android and other targets. These were not available at the time that I created this blog post.

Pictured: Actuate Example (Haxe) running on Windows 7, an HP TouchPad, an HP Veer 4G, an LG Optimus S and the Xcode 4 iPhone simulator

This is a screenshot of my previous Actuate example, running on Windows, webOS, Android and the iPhone simulator. With the NME install tool, do you want to know how easy this is? Of course you do: Continue reading Android, iOS, webOS (and More!) — Cross-Platform Made Easy