Hello World Command Line


"Hello World" is a common example of getting started with programming, here we will show you how to add Hello World with HaxeFlixel's FlxText. You can compile this test for any supported target platform.

Using the command line with HaxeFlixel is made easier with our custom built flixel-tools utility, also made with Haxe.

Installation of flixel-tools

You first need to install and setup flixel-tools - please refer to this guide for doing so.

Create a new HaxeFlixel Project Template

HaxeFlixel requires a basic structure of files for any project that you can automatically create with the template command (tpl for short).

flixel tpl -n "HelloWorld"

You will now see a new folder named "HelloWorld" with all the files for your project being created automatically.

Add the "Hello World" FlxText

Adding the text is as simple as opening the PlayState.hx file in the newly created source folder.

The file will look like this:


import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.text.FlxText;
import flixel.ui.FlxButton;
import flixel.math.FlxMath;

class PlayState extends FlxState
    override public function create():Void

    override public function update(elapsed:Float):Void

All you need to do is add the following in the create() function:

add(new FlxText(0, 0, 0, "Hello World!"));

Save the file and return to your command line window. Now we can compile the project.

Without running the lime setup commands you can compile to Flash, Neko and HTML5 out of the box.

Test your project with the following commands:

lime test flash
lime test neko
lime test html5

If you struggled through any part of this tutorial, ask a question on our forum :)