Introduction
NME is an easy-to-use, cross-platform framework, perfect for game or application development.
The APIs follow the Flash API closely. This should make NME especially familiar if you have Actionscript experience. The API is also easy to understand if you have not worked with Flash before.
If you are new to programming, please visit the New Developers' Guide. This will help introduce you to the Haxe programming language, as well as basic programming concepts.
If you have experience with Actionscript, you be interested in visiting the AS3 Developers' Guide, which includes more details about the simularities (and small differences) between Actionscript 3, Flash, Haxe and NME.
架構介紹
NME全程NekoMedia Engine,基於Neko的一個多媒體引擎,NME在Neko的基礎上添加了SDL架構抽象多媒體硬體相關操作,添加常用2D遊戲開發API,提供了一套以Haxe為語言的跨平台解決方案,只用編寫一次就能發布到iOS, webOS, Android, Windows, Mac, Linux, Flash Player等平台。
- 目標平台Windows/Mac/Linux and iOS/Android/webOS,轉換後採用native語言;
- 可編譯到Flash, so compile it for the browser.
幾個主要工程:
- Neko, 源碼翻譯為.n位元組碼,提供虛擬機器執行位元組碼,提供了一種跨平台的能力;
- Haxe, Haxe源碼可以轉換為JavaScript、as3、Neko位元組碼、cpp、php等;
- hxcpp, 如果目標語言為cpp,則需要該工程提供運行時支援;
- sdl-static,平台Win32, Mac OSX, iPhoneOS and Linux32下的靜態庫編譯;
NME主要組成部分:
- 仿照Flash的API結構,採用Haxe語言寫的API層;
- 針對目標平台預先編譯的庫支援,包括sdl,opengl,regexp,zlib等,只在平台Windows, Mac, Linux and webOS使用了sdl;
針對ios、android、win、webos、mac、linux平台,Haxe將源碼轉換為C++代碼,之後在目標平台與先行編譯的庫進行編譯\連結,以達到native的效率。
How It WorksPublishing to a Flash SWF
If you publish to Flash, NME will use the Haxe language compiler to generate a Flash SWF from your code. The compiler is very fast and reliable. Haxe was built by the same team that created MTASC, the original open-source Actionscript compiler.
Once your SWF has been created, NME embeds your assets directly into the SWF. If you would prefer to keep assets separate, you can still use nme.display.Loader and nme.net.URLLoader to load external assets. NME embeds only assets you have defined in your NMML project file.
Publishing to iOS
If you publish to iOS, NME will use the Haxe language compiler and the HXCPP library for Haxe to generate C++ class files. These are combined with a Flash-like "standard library" for iOS, composed of C++ and Objective-C class files. Your code and your assets are pushed into an XCode project that is generated for you.
When you are ready to compile, you can open the generated project in XCode and publish to the iPhone Simulator, a provisioned iPod Touch, iPhone or iPad, or any other target XCode may provide.
In development builds of NME, it is also possible to publish directly to the iPhone or iPad simulator, without opening XCode, using the "test" command and the "-simulator" or "-simulator -ipad" flags.
Publishing to webOS
If you publish to webOS, NME will use the Haxe language compiler, combined with the HXCPP library for Haxe, to generate C++ classes from your code. This is combined with a Flash-like "standard library" for webOS, written in C++. NME will then use an ARM g++ compiler to create an executable binary for your project. If you are using Windows, this will be the CodeSourcery ARM GNU/Linux g++ compiler that is recommended by HP. If you are using Mac or Linux, the toolchain is already installed with the webOS SDK.
With your executable compiled, NME will combine your application with your project assets and generate a webOS application (IPK) using the standard webOS SDK tools. If you like, NME will also install the application on a connected webOS device and run the project.
Publishing to Android
If you publish to Android, NME will use the Haxe language compiler, as well as the HXCPP library for Haxe, to generate C++ classes from your code. NME will also generate supporting Java classes for your application.
NME then combines your code with a Flash-like "standard library" for Android, written in Java and C++, and compiles using the Android NDK and Android SDK. By running an Apache Ant process, the build process is completed, and if you like, your application is installed to a connected Android device and run.
Publishing to Windows
If you publish to Windows, NME will use the Haxe language compiler, as well as the HXCPP library for Haxe, to generate C++ classes from your code. Combined with a Flash-like "standard library" written in C++, NME will use the Visual Studio C++ command-line compiler to generate a native Windows application.
Your application and supporting assets are copied to a single build directory, and if you like, the application is also run.
Publishing to Mac or Linux
If you publish to Mac or Linux, NME will use the Haxe language compiler, as well as the HXCPP library for Haxe, to generate C++ classes from your code. NME will then combine your code with a Flash-like "standard library" written in C++ and compile a native executable using the g++ compiler installed on your system.
If you are using a Mac, g++ is usually provided by XCode. If you are using Linux, g++ will probably be installed on your system already. NME supports 32- and 64-bit builds, so you can compile for either or both, so long as you have the necessary libraries on your system to cross-compile. NME will copy your application and supporting assets to the same build directory, and if you like, run your application.