[nme][game.dev] Neko Media Engine简介

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.

几个主要工程:

  1. Neko, 源码翻译为.n字节码,提供虚拟机执行字节码,提供了一种跨平台的能力;
  2. Haxe, Haxe源码可以转换为JavaScript、as3、Neko字节码、cpp、php等;
  3. hxcpp, 如果目标语言为cpp,则需要该工程提供运行时支持;
  4. sdl-static,平台Win32, Mac OSX, iPhoneOS and Linux32下的静态库编译;

NME主要组成部分:

  1. 仿照Flash的API结构,采用Haxe语言写的API层;
  2. 针对目标平台预先编译的库支持,包括sdl,opengl,regexp,zlib等,只在平台Windows, Mac, Linux and webOS使用了sdl;

针对ios、android、win、webos、mac、linux平台,Haxe将源码转换为C++代码,之后在目标平台与预编译的库进行编译\链接,以达到native的效率。

How It Works


Publishing to a Flash SWF

Publishing 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

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

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

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

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

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.

posted @ 2012-03-22 00:40  zsounder  阅读(1529)  评论(0编辑  收藏  举报