New Releases!

Finally, I’ve managed to make a few more releases. Namely, HXCPP 2.06 and NME 2.0.
HXCPP can be downloaded via “haxelib”, and works with the new 2.06 version of haxe. This release contains many bug fixes and optimizations. Also, when you compile with the -debug flag, you can get additional null checks and stack dumps.
NME 2 is a complete rewrite from the ground up. Most of the logic has been moved from neash to the c++ code for optimization reasons.
For NME developers this only means a couple of things:

  • You use –remap flash=nme instead of –remap flash=neash
  • The “boot” code has changed, so you will need to follow the main line from one of the samples.
  • Improved performance!

I updated my Xcode SDK, which caused a bunch of link errors linking for the simulator with the NME library. It seems Apple have changed the “ABI” for objc (basically, broke binary compatibility). So I must choose pre 4.0, post 4.0 or both. I think I am going to require NME iphone simulator users to have the latest SDK – unless there are any objections?

iPhone Xcode Template

I finally got around to making an Xcode template for haxe compiling. Try it out and let me know if it works. It’s my first one, so I’m open to ideas for improving it.

To use the template, first extract it to your developer template area, eg: /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application.
Then when you create an new Xcode project, this template should show up. You should be able to build for the simulator.

To build for a real device, you will need to go though the official Apple developer program, and get yourself signed up. Then you need to get your certificates in order, and finally edit the “plist” file in the Resources folder and change the company URL to match the one you used in your certificates.

You can edit Main.hx code in the “haxe/src” directory, but you will probably want to locate your haxe source tree outside your project area, since we are multi-platform developers an do not want to tie ourselves to Xcode. To do this, you can edit the class path in the Build.xml file, and change the boot code in IPhoneMain.hx. It is done this way so the haxe-generated library always has the same name. If all else fails, you can have a look in the makefile, which is set up to allow building debug and release versions for iphoneos and simulator without having to change other project settings.

Let me know if you have any luck.

33 Replies to “New Releases!”

  1. unfortunately it is not compiling for me. Any suggetions? (osx 10.6.4)

    neko Sample.n
    Called from nme/display/DisplayObject.hx line 438
    Called from nme/Loader.hx line 8
    Called from neko/Lib.hx line 33
    Uncaught exception – load.c(232) : Failed to load library : nme.ndll (dlopen(nme.ndll, 1): image not found)

  2. Hi scorpion,
    Neko has trouble finding the dynamic libraries.
    On mac, you can set the environment variable
    DYLD_LIBRARY_PATH to point to the nme/ndll/OS directory. On linux, it is LD_LIBRARY_PATH.
    Also, make sure the HXCPP/bin/OS/nekoapi.dso is in your path too – easiest may be to copy it into the NME directory.


  3. Hi Hugh,

    How’s the Android development coming along? Would be great if we could get some tutorials on the subject, maybe a template. Appreciate what you’ve done thus far, hope to see some good stuff in the future.


  4. it run nice on iphone and ipad .is there any document for hxcpp on android? i try to compile it but it show error on my milestone, i have include there any suggestion? i just want to see same haxe code can run on both platform.

  5. Very cool! I actually got everything to compile!

    I look forward to making games with this.

    Unfortunately it seems that nothing is anti-aliased. How would one go about anti-aliasing stuff?

    Also it appears that changes to IPhoneBuild.hx aren’t applied when built. I tried doing “make clean” but it didn’t help. How do you incorporate those changes?

    1. Alec, as for changes ti IPhoneBuild.hx, have a look in the “BuildResults” panel and see if it is “Running External tools”. There might be some error there.

  6. Also, how do you get physaxe to work?

    When I run it, I get an error about g not being defined, which leads back to

    #if (flash || neko)
    var g : flash.display.Graphics;
    #elseif js
    var g : phx.JsCanvas;

    So I add -D flash to Build.hxml and now it gives this error:

    ./src/nme/geom/Matrix.cpp:287:0 ./src/nme/geom/Matrix.cpp:287: error: no matching function for call to ‘nme::geom::Matrix_obj::__new()’

    I know you got physaxe running before so would you mind putting together a guide?

  7. Hi Hugh,

    Ported a simple haxe flash game straight to iPhone with your new template without even breaking a sweat. Performance is excellent as well, Cheers!

  8. Thanks for the tip Tony. I will be sure to check that out, it seems pretty good.

    Anyone have and answer to my anti-aliasing question?

    Also, Hugh, your work is incredible. I think the fact that there are so few comments is a sign everything is working perfectly for most people. Did you embark on this project using the picture of Steve Jobs’ face when he finds out people can make awesome games for iPhone and Flash using one code base?!

    The only thing that could make this more awesome would be some way to make the native features available to haxe programs (events on close, sleep, etc.) but that is out of this project’s scope. Also, since Palm released their PDK, does this mean that you will soon support webOS as a build target?

    1. Hi Alec,
      For physaxe, you have to replace “if (neko||flash)” with “if (neko||cpp||flash)”, or “if (nme||flash)”. You will also need to boot (“main” function) code from the samples. And finally, you need to do “–remap flash:nme”.

      I’m also taking the lack of comments as a sign that eveything works 🙂 I don’t want to hassle Steve Jobs too much, in case he decides to ban the haxe apps.

      As for native features, things like close etc. I will add, since it is good to “play nice” with it OS. However, things like GUI views etc. are probably best done in the Xcode project itself, even though this means getting your hands dirty a bit.

      I think you can turn on line AA using the Stage.quality property. Not sure about polygon AA in opengl mode – but you can “cacheAsBitmap” or BitmapData.draw to get a software render, which you can then use as a Bitmap texture.

      I actually have some patches for a webOS version – just need time to apply them. It’s a bit hard to test for me without a device though.

  9. Thanks Huge! The physics engines work now!

    Unfortunately I can’t get anti-aliasing to work:

    flash.display.Stage.quality = flash.StageQuality.BEST

    gives me:
    src/Main.hx:48:0 src/Main.hx:48: characters 2-29 : nme.display.#Stage has no field quality

    1. Hi Alec,
      You need an instance of the stage:
      flash.Lib.current.stage.quality = flash.display.StageQuality.BEST.
      The instance will only be valid after nme has been initialized and you callback is called.


  10. I must be placing it in the wrong place. I tried putting it in the constructor of Main and right after nme.Lib.Create and neither worked.

    Where should I put it?

  11. Hi Hugh

    I’m trying to compile nme2 on Ubuntu 10.04/64 bit, although the problem below is not a 32/64 bit issue:

    nme/2,0,0/project# haxelib run hxcpp Build.xml -DHXCPP_M64
    gcc -c -fvisibility=hidden -O2 -fPIC -DHX_LINUX -I/usr/lib/haxe/lib/hxcpp/2,06,0//include -Iinclude -I../../sdl-static/include -I../../sdl-static/include/SDL12 -I/usr/include/SDL -frtti ./sdl/SDLSound.cpp -oobj/linux//sdl/SDLSound.o
    ./sdl/SDLSound.cpp: In member function ‘virtual double nme::SDLSound::getLength()’:
    ./sdl/SDLSound.cpp:165: error: ‘struct Mix_Chunk’ has no member named ‘length_ticks’
    Called from ? line 1
    Called from BuildTool.hx line 899
    Called from BuildTool.hx line 451
    Called from a C function
    Called from BuildTool.hx line 475
    Called from BuildTool.hx line 548
    Called from BuildTool.hx line 581
    Called from BuildTool.hx line 181
    Uncaught exception – Error : 256 – build cancelled

    Looking at struct Mix_Chunk in SDL_mixer.h the compiler is of course entirely correct that ‘struct Mix_Chunk’ has no member named ‘length_ticks’. This is true for SDL 1.2.8 on my install, and also for 1.2.11 in the SDL repo.

    What version of SDL are you targeting with nme2?

    From the code in ./sdl/SDLSound.cpp:165 it looks like the value that should be returned by SDLSound.getLength() is the length of the wav file in units of milliseconds. Is that correct?

  12. Hi,

    First thanks for your great work but i’m having trouble to build for Iphone Devices everything is ok for Simulator but when i try to build for devices i get a lot of errors..

  13. Hi Hugh,

    Fantastic work! I’m interested in implementing the camera UI / or use of the camera. Do you think it can be done in NME2? Is this something you are already working on? – It would be great to hear your thoughts?

  14. hi hugh,

    massive thanks for putting this together… i’m unable to build directly from the template provided here, though, wondering if there’s something obvious i’m missing.

    I’m using the template from the link in this post and XCode 3.2.3. I get a total of 31 errors ranging from missing string.h, Wchar.h and Typeinfo.h to declaration of ‘operator new’ as non-function in /usr/lib/haxe/lib/hxcpp/2,07,0//include/hx/Object.h

    I’m wondering if this is just a path problem – like i don’t have something defined correctly or pointing to the wrong place, or an outdated version of hxcpp?

    any help you could give would be much appreciated.


  15. I had this running smoothly with iOS 4.2 and Xcode 3. However, even just the instructions for adding the project template don’t seem to work for Xcode 4. Can you explain how you originally created the template? Do you know of any changes that might be required to make the template compatible with Xcode 4?

  16. Hi,
    I am moving away from the template system. The new system will work on on all platforms, and starts with a NME-project file, and then generates all the xcode files. Hopefully this will make things easier to update + maintain.
    I built the template by a method similar to this and then replaced bits with the xcode template sysntax.

  17. i got this to work after some hunting and prodding … very cool! a few gotcha’s i encountered, if anyone else might find my quick notes any use:

    ==== 1. simulator
    Xcode 3 base sdk issue: Project -> Edit Project Settings -> Build -> Base SDK -> set to something that’s not missing

    Project -> Set active target -> Build Haxe

    complaining, whoops, of course: download & install haxe =)

    was missing some things, in iTerm:
    axelib install hxcpp
    haxelib install nme
    haxelib install neash

    Project -> Set active target -> HelloHaxe

    worked for simulator!

    ==== 2. device
    got errors compiling for arm7 … “_hxRunLibrary”, referenced from

    project -> edit project settings -> Build -> Valid Architectures -> “armv6 i386”

    build worked! error: no provisioning profile. go make an adhoc mobileprovision from apple’s ios portal. load in keychain, xcode, phone.

    HelloHaXe-Info.plist -> Budle identifier ->

    got it on iPhone 3GS!

    game on 😉

  18. hi Huge,

    I would appreciate your help with something…. I hope it’s ok to ask 🙂
    we are developing a game using the Citrus game engine and box2s. the project is written in haXe (our algorithm guy develops in Flash and port it to haXe).
    we are considering the haXe-nme environment as our development architecture.
    I wanted to consult with you – the game will use the iOS camera feed to create a video clip. i have written an iOS nme extension to pop the camera as a full screen and it works great. the thing is that we need the iOS camera view to act as the background view, and on top of it draw elements using the Citrus engine, which, as i understand, uses an SDL window for display on the iOS.
    I’m wondering what is the best way to go about this….
    i think i might have to write an iOS extension which uses the iOS AVCaptureStillImageOutput class, and somehow transfer the screen capture to the nme extension to draw. if that would be possible, the performance is my biggest worry.
    I would love to hear what you think about this, and maybe point me to some other direction. I’m new to the nme framework, so sorry if my question sounds a little weird…

    anyways, thanks a lot for your help !!!
    have a good one,

    thank you so much for your time,
    i hope it wasn’t rude to address you with this issue….

    have a great day, and thanks again,

Leave a Reply

Your email address will not be published. Required fields are marked *