00:00
00:00
migmoog
So handsome it hurts

Emperor

Boston

Joined on 6/3/20

Level:
22
Exp Points:
5,103 / 5,380
Exp Rank:
9,106
Vote Power:
6.37 votes
Audio Scouts
2
Art Scouts
1
Rank:
Police Officer
Global Rank:
15,619
Blams:
292
Saves:
333
B/P Bonus:
10%
Whistle:
Normal
Trophies:
26
Medals:
738
Supporter:
2y 2m 28d

An in depth guide on setting up HaxeFlixel

Posted by migmoog - April 12th, 2021


Thanks to a certain super popular game here on NG, the game engine it was made with, HaxeFlixel, is receiving a HUGE influx of new users. A good chunk of these people aren't familiar with code, and thanks to haxeflixel's (which from now on I'll just call flixel) unorthodox setup it can be hard to get into. However, I do think the setup guide is good, but I think the average new gamedev won't understand what the commands they're running are doing or even what the command prompt is. So I'm writing this to help explain what's happening in the setup and what you're actually doing.


Haxe and Haxelib

To start, you'll need to download Haxe, the programming language that flixel uses. The installation is very simple, just run the exe and you'll have haxe installed! Something that new users think is that haxe is like any other program you use on you're computer, i.e. you click an exe and a window will pop up. Haxe is NOT that kind of exe, it is a command that is run inside the command prompt. What is the command prompt? It's an application that comes on all computers, where you type in commands that run some actions. It is VERY important that you understand how to use it for this guide, and for programming in general. Ninjamuffin has a nice guide on how to use the command prompt, so I recommend you check it out if you have no clue on what it is or how it's used, and when you're done, come back here.


After downloading haxe, you'll have access to the haxelib command. Haxelib is very important, it's a command that allows you to download other people's published code (also called libraries or libs) from the haxelib site into your haxe installation to use in your projects. This is where you get flixel and its other parts from!


The Elements of HaxeFlixel (Lime, OpenFL, and Flixel)

With the haxelib command, you'll first have to use it to install 3 libraries. Lime, OpenFL, and flixel. To understand why you need these you need to understand what flixel is made of. Flixel is written on top of the framework OpenFL, which is much lower level, meaning less like a game engine and more agnostic for other applications. OpenFL is a framework that recreates the old Flash API (The code that flash gamedevs used to make flash games), and flixel is written on top of it to help it port to other platforms like HTML5, Windows, and Mac. OpenFL is also written on top of another framework called lime, which is where its portability and ability to render on any device comes from. Obviously lime is much lower level than OpenFL, and when you install lime you'll to create a command that allows you to compile your games to flixel's platforms. If you were to download any of these without the others, they wouldn't work.


To download these, you need to use the "haxelib install <library name>" command, which downloads the library from the Haxelib site and enables it for use in your projects.


haxelib install lime

This installs the lime library, which we'll have to set up the lime command for later

haxelib install openfl

This installs openfl, which will help flixel's code actually compile without errors.

haxelib install flixel

This is the actual haxeflixel library, which is what you'll write your games with. All the openfl/lime stuff is under the hood and you won't actually have to deal with it when you're coding.

haxelib run lime setup flixel

While installing flixel downloads the game framework itself, it has a plethora of other libraries to help with your game development (ui, addons, etc.). Using this command will download those libraries all at once, so you don't have to install them all at a time.


And with that, we have the libs, but there's still a bit more work ahead. Now we need to setup the flixel command to create templates for our projects, and the lime command so we can compile our games.


The lime and flixel command setup

When it comes to using flixel, there will be 2 commands that you'll be using. The first is "flixel", which helps you with the flixel library itself, configuring it for code editors and making project templates. The other is "lime" which will compile your game so it will run on different platforms.


Here are the commands you will run to set these up:

haxelib run lime setup

This sets up the "lime" command, allowing you to build for the platforms you want such as html5. To test a game for html5, all you need to do is run:

lime test html5

This will build the game for the browser (html5) and run it, if you want to build for other platforms such as "lime test windows", you'll need to do the setup. So if you don't do "lime setup windows" you won't be able to compile your game to windows.


Next is the flixel setup

haxelib install flixel-tools
haxelib run flixel-tools setup

This downloads the flixel-tools library, which is what will give you the flixel command. The second command runs the setup for flixel-tools, which actually enables the command in the command line.


Now you have all the required libraries, and commands to use HaxeFlixel. If want to learn the game engine and how to use these commands, read the HaxeFlixel tutorials!


Tags:

8

Comments

That is very well put, but i think people new to haxe should learn how to use the programming language and its features first and then openfl and the flixel https://keyreal-code.github.io/haxecoder-tutorials/

This is about haxeflixel installation, and you can learn those things in tandem.

@HENOOB naah, don't be a purist about it. Don't make every kid learn Java before they can do something enjoyable, especially if it's a hobby. Learning haxeflixel IS learning Haxe in a way, since it's the language it runs on. Saying that you need to learn OpenFL as a fundamental for Haxeflixel misses the point; It's a framework that makes it easier to get started. If you're making something conventional then you don't need to touch OpenFL, it's just what powers HF.

@BobbyBurt if that's your point i think only learning Haxe is sufficient to use HaxeFlixel, but i think some people that wants to make a game not only as a hobby should learn some of the openfl functions compatible to HaxeFlixel like creating a custom preloader, adding video playback, adding SVG graphics and so on

You're kind of missing the point of HF. It exists so you *don't* have to make a game with openfl. And you're not wrong to say learning some of these openfl functions are handy, but these are really things someone can learn further down the line. If you're the kind of gamedev learning Flixel you won't really need to write your own preloader.