Several questions about HTML5 development

  • Hi Everyone,

    For HTML5 game I've been using phaser because it solves some things in an easier way and It seems to work faster on that platform alone.

    The problem with phaser is that it is slower for mobile native games so I want to go back to use Flixel to develop games. I made this Phaser demo with all the basic features I need on an HTML5 Game:

    I would love to reproduce the same demo using Flixel. I have several questions about HTML5 things that I solved using phaser but I'm not sure how to do them on HaxeFlixel:

    • How does the server work? Every time I compile the game opens on http://localhost:2000/ but I'm not sure what server it is using. I would love to be able to set up some things for the server.

    • Can I setup a local server that allows me to enter from different devices than the development machine? This is useful for mobile testing. I tried opening the local host from other devices but doesn't work. On phaser I'm using Budo for the server that allows me to enter from other devices using the ip address of the development machine.

    • How can I detect if the device was rotated?

    • How can I detect the device of the user to know if it is desktop or mobile?

    • SWF support works really bad. I hope this improves with the new OpenFl. Is there any date for the new openfl support for HaxeFlixel?

    • How is the correct way to use audio assets? On Phaser, I made several audioSprites on several formats for each browser compatibility. Does HaxeFlixel support audio sprites? What is the best format for audio?

    I hope to get answers here because there is not a lot of documentation about HTML5 development with HaxeFlixel and it is one of the most important platforms for our studio right now.


  • To host your HTML5 on a local server:

    1. Go to your html5 bin folder which has the .html
    2. Open the Command Prompt there (Shift + Right Click > Open the command window here)
    3. Type in nekotools server
    4. Hit Enter
    -h [domain] - set hostname
    -p [port] - set port
    -d [directory] - set base directory
    -log [file] - set log file
    -rewrite - activate pseudo mod-rewrite for smart urls

    That's the first two questions.

    And to answer the 4th: to detect if a user is on desktop or a phone, you will want to use FlxG.onMobile. It's been added a while ago but I guess it was not publicly noticed.

  • Thanks for the answers!

    I'm not able to enter to the server from devices on the same network. How can I solve that?

  • This should help.
    I have this problem myself sometimes, randomly for no reason. It just could not access but after a while it could.

  • Hey for the testing with other devices you can create a python web server and you should be able to test out other devices


    1. Need to download python and be able to run it in command prompt
    2. Go to your export folder with you html file and run command prompt in that location
    3. run the following command
    python -m http.server 8000

    8000 can be replaced with any port number you would like to use.

    Added benfit of this approach is that you can also port forward the same port for the python web server so you can test out your html5 game/website/etc across the internet.

  • Also to answer audio for html5 you are supposed to use mp3 . Screen rotation can be detected through js.Browser.document you should be able to find documentation through javascript if you can't find it let me know and I'll write something up. Haxeflixel new update info is in the haxeflixel blog. and from this he has now made a trello and can ask him questions on the pull request for haxeflixel on GitHub link is at bottom of blog.

    Finally My thoughts on the current state of html5.
    Desktop html5 is powerful enough to be able to run most games as long as not to many effects with many sprites are being used. But the mobile performance for html5 is insanely bad and if that is something you want to support haxeflixel is not the right choice. Also with many things you will encounter with html5, importing js and using that code specific html5 libaries gives the best results in solutions with html5 specific problems so keep your eye out for those issues with browser display , showing video, saving cookies etc.

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.