haXe, NME, RobotHaxe, Git, GitHub, brains exploded

Hell yeah! Crazy day. Spent all day figuring stuff out, now I’m pretty tired but I have to share my findings.

NME, a cross-platform solution

So, I am looking for a true cross platform development solution that will give me output for iOs, Android and Web (Flash). Using Flash and Air is too slow for me, but I do like ActionScript 3 a lot so NME seems like the logical solution. What is exactly NME? You know what? I don’t really know. It uses haXe and I think haXe is a programming language based on ActionScript. NME can compile both to Flash and C++ (and many more). That is as much as I could figure out, but I’ll keep digging.

Installing haXe and NME seemed pretty straight forward and it seemed to have worked, the only trouble I had was with FlashDevelop. Syntax high lighting is all off and it doesn’t seem to find where the classes are. But it compiles so I could at least get some stuff done.

From ActionScript to haXe

Actually that part isn’t that bad, there are little differences which you can find on this cheat sheet, but there are also concepts that are totally oblivious to me like the Dynamic type. But I just rolled with it and everything kept working, so this is something I’ll figure out later too. Little annoying thing every class needs a constructor (but at least the function name is only “new”) and if you extends something, you have to call super. Also, I noticed that on the NME Sprite (nme.display.Sprite), there is no rotationY property (well this is particular to NME, and I have never used rotationY before until 2 days ago, so I find this very funny).

On to RobotHaxe

Well I can’t really do anything without Robotlegs. I like how simple things are with it and well organized, so if I was going to move to another language, it needed to have Robotlegs. Period. Well I also need to be able to embed Fonts, have a Tweening engine and something to replace timeline animations, Robotlegs is the most important. Turns out there is a port to haXe called RobotHaxe made by David Peek. The only problem, there is no documentation, no examples, no tutorials… I decided to give it a shot anyway, how hard could it be? Kinda hard… haha. Anyway I got it to work, not sure it is the best way to do it, but it works (for what I have tested). I made this test RobotHaxe project using FlashDevelop and NME, not sure what it implies but I think it can be useful to people so I am giving it to you.

Git and GitHub

I never used Git before, always used SVN so that was new territory also. I also used to make a zip file and give my sources like that, but I figure GitHub is a better solution since you can browse before downloading. Anyway I put my test project on it. So go check it out here : Example RobotHaxe Project for NME and give me feedback or tell me how I could do it better, because I really don’t think it is perfect. But it is better than any other example out there. ( I know there is a bunch of guys using RobotHaxe for JavaScript, but the code I have seen from them wouldn’t work in Flash so it wasn’t really helpful)

, , , , , , , , ,

  1. #1 by Joshua Granick - February 2nd, 2012 at 19:08

    I’ve been using NME for games for over a year, and have been working a lot to make it even better. I’ve been very happy with it, and would love to help however I can :)

  2. #2 by Guillaume malartre - February 2nd, 2012 at 19:34

    Hi, your example is a bit misleading. I think the mediator map rule should be created in your context and not through a command. Thanks for sharing! I m eager to see if the haxe swc with inject metadata would be outputting the same infos as a standard flash swc so we could mix haxe swc with a flash project.

  3. #3 by Phil - February 2nd, 2012 at 23:16

    I found this post very accurate. I like the prospect of NME and have experimented a little but unfortunately I have not found the documentation / examples to really get me rolling. I was seriously considering using it for a mobile project, but stage3d for ios/android is right around the corner (like any day now) and the performance looks good so I will roll with that. But I will definitely keep an eye on NME since the ecosystem is sure to evolve. I’d be really interested in a postmortem once you are done your project.

  4. #4 by zedia.net - February 3rd, 2012 at 13:59

    @ Joshua Granick Thx a lot

    @Guillaume malartre I have always been doing that. There are so many additions to the mediatorMap that I tend to want to free my context from it, some people do the same for the models and the commandMap. I don’t think that is misleading at all :)

    @Phil Will do!

  5. #5 by Joshua Granick - February 3rd, 2012 at 14:14

    @Phil Since NME can publish to Flash, you have the support of the full Flash API, if you choose. One of the reasons why I have not been worried about using NME is that if Adobe comes out tomorrow, and surprises me with something awesome, I can still support it without rewriting my code.

    In the event that Adobe does not surprise me (which has long been the case) then I can continue to move forward with something that practically meets my needs as a developer.

    I would love to help in any way I can with practical samples or examples, so if you have anything which appears missing that you have in mind, just let me know.

  6. #6 by zedia.net - February 3rd, 2012 at 14:22

    @ Joshua Granick
    But to get the full support of the Flash API you have to use the Flash definition for classes right? And that won’t compile to other target like iOs. Like for example the NME Sprite doesn’t support rotationY, if I want to use it I will only be able to compile for Flash. Am I getting this right?

  7. #7 by Joshua Granick - February 4th, 2012 at 04:16

    NME does not support the 2.5D APIs (rotationX, rotationY, rotationZ, etc) from Flash 10 right now. You are correct — if you reference a flash.* class that isn’t implemented in NME, it will not compile for targets other than Flash.

    Targeting AIR is a Flash target. If I decided that I wanted to use AIR instead of NME, I wouldn’t have to write anything. I could continue to support Adobe’s APIs using Haxe code. Otherwise if I wanted to mix-and-match, Haxe supports conditional compilation, like #if flash #else #end, so I can include a platform-specific API without breaking compilation for other platforms.

  8. #8 by cem ocalan - February 8th, 2012 at 14:43

    Hi, I tried out RobotHaxe’s injector on a C++ target. Your example help me a lot but had problems when compiling to windows.

    So in the end, I made some changes to RTTI file to exclude NME source from the macro, which seems to solve the problem. There is still a standing issue with interface classes that get corrupted from the macro.

    Have a look if you like, it might help somebody;
    http://dl.dropbox.com/u/8149332/nme/RTTI.hx
    You need to change the compiler flag to include package names like this;
    RTTI.generate(['org', 'com'])

  9. #9 by Yasser - March 25th, 2013 at 16:45

    Hi, I made a little game with haxe nme. But I have a big problems. When I tried to play it in an Ipad I couldn’t heard anything. Someone knows how can I play sounds in an Ipad. The game works fine in others browsers@ Joshua Granick

(will not be published)
Subscribe to comments feed