Build 10 games and learn game development along the way in this fast paced game development course

Get the source code of 12 commercial games, loaded 50+ million times, and learn the secrets of game design

Learn how to make a successful Flash game from a real world example. Fully commented source code

Create realistic Flash physics games from scratch with advanced features, from Angry Birds to Crush the Castle

Create cross-platform games coding only once with Flambe and Haxe

Let me introduce you Flambe, a free 2D game engine that allows you to make cross-platform development, especially HTML5 and Flash. You are going to write games in Haxe: an open source, AS3-like language with expressive features and a fast compiler.

Before we start coding with Flambe, there’s a couple of packages we need to be installed on our computer. The following guide was made with a Windows computer, but it’s almost the same thing if you are using a Mac.

Download Haxe
Download NodeJS
Download Java runtime

Once you have installed all the software required (and probably rebooted your machine) look for in your computer for Node.js command prompt (it should be in C:\Program Files\nodejs\nodevars.bat if you use Windows) then type in it:

npm install -g flambe

You should see a lot of text, then:

flambe update

And now Flambe is ready to be used.

Create a new project called helloworld with

flambe new helloworld

at this time a folder called helloworld should be created, with a lot of stuff inside. At the moment, there’s a simple demo of an airplane, but I changed it in order to create my own demo.

I will create a ball which will move towards mouse (or finger) pointer when the stage is clicked (tapped).

I uploaded an image of the ball called ball.png in the assets/bootstrap folder, then in src/urgame you will find an Haxe file called Main.hx which is the one we are going to edit. You can use your favourite text editor, you’ll see Haxe is not that different than AS3, anyway here’s the API guide.

Now, the code of Main.hx:

Once you’re done with coding, in the command prompt type

flambe build flash --debug

or

flambe build html --debug

to build a Flash or HTML5 version of the project, then

flambe serve

to start a webserver and look at your project at http://localhost:7000. Removing --debug parameter will export the project for distribution, generating a smaller and faster build, which is slower to build and harder to debug.

And this is the result:

Select the mode you prefer, then click on the stage to move the ball.

Download the entire project

Soon, a complete game using Flambe and Haxe.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (9 votes, average: 4.44 out of 5)
Loading ... Loading ...
Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 3 comments

  1. lordkryss

    on November 29, 2013 at 7:14 pm

    I’d recommend you to remove the link to “getflambe.com” (that I think it’s just a test page), and link instead the offial repo on github https://github.com/aduros/flambe and the non-official but more documented wiki on https://github.com/markknol/flambe-guide/wiki so that people will not comment “the links on the website don’t work” :P

    I’ve been using flambe for a few months now, and it’s been really good so far.
    Note that it supports both canvas2d and webgl for HTML5 and only stage3d for flash/air.

  2. Create cross-platform games coding only once with Flambe and Haxe | Adobe

    on November 29, 2013 at 7:17 pm

    [...] Emanuele Feronato Flambe is an excellet free tool to create cross-platform games coding only once in Haxe, a script [...]

  3. Bruno Garcia

    on February 11, 2014 at 6:55 pm

    I hear AddictingGames.com, a major online game publisher, is looking to expand into HTML5 and mobile games. After evaluating different game engines, they’re choosing to fund cross-platform HTML5 and Flash games written in Flambe with Haxe.

    If this sounds interesting to you, get in touch with them on Twitter!
    https://twitter.com/AddictingGames/status/431170196523335680
    https://twitter.com/AddictingGames/status/433031381371736064

    Full disclosure: I’m the author of Flambe.

Thank you for the download!!

I hope you will find it useful and make something interesting out of it

To keep up to date with the blog, why don't you like my Facebook page and follow me on Twitter?

Want to learn more? Don't miss this:

Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now

×