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.

This entry was posted in Blog, hxcpp, neash, nme and tagged , , , . Bookmark the permalink.

33 Responses to New Releases!

  1. m5no1 says:

    NICE WORK!!!!!!!!!!!!!!!!!!!!!!!!!!

  2. Ivan says:

    You are making one amazing product! Thank you!

  3. Franco Ponticelli says:

    It works smoothly, thank you very much!

    p.s. Build.xml should be Build.hxml

  4. robo says:

    any video tutorial will be pleasure…

  5. scorpion says:

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

    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)

  6. Huge says:

    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.

    Hugh

  7. Fintan says:

    this is great! The red circle displays on my iPod Touch with no problems at all.

    thanks for all your hard work.

  8. ffllk says:

    how about hxcpp targeting airplaysdk?

  9. JJ says:

    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.

    JJ

  10. m5 says:

    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 nme2.is there any suggestion? i just want to see same haxe code can run on both platform.

  11. Alec says:

    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?

  12. Alec says:

    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;
    #end

    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?

  13. Jarrad says:

    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!

  14. tonypee says:

    Alec, try using box2dhx – it works well.

  15. Alec says:

    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?

  16. Huge says:

    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.

  17. Huge says:

    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.

  18. Alec says:

    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

  19. Huge says:

    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.

    Hugh

  20. Alec says:

    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?

  21. scorpion says:

    It works great! Thanks for your hard work.

  22. Conrad says:

    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?

  23. alchymi says:

    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..

  24. jk says:

    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?

  25. Radu says:

    can i use the swf-lib to get movieclips from a library swf on iphone? i tried it with no luck

  26. M Doch says:

    Does anyone know whether this still works with the 4.3 ios beta?

  27. 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.

    T

  28. TM says:

    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?

  29. Huge says:

    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.

  30. Pedro says:

    in Xcode 4.0.1 Build 4A1006 the template doesn´t show in “new project”…

  31. Huge says:

    Hi, I am working on a new project system. This will be ready in the next version.
    Hugh

  32. starpause says:

    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 -> SRCV73LMEK.com.organic.HelloHaxe

    got it on iPhone 3GS!

    game on 😉

  33. Lior Lasry says:

    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,
    Lior.

    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,
    Lior.

Leave a Reply

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