I've been looking through the sites of Haxe / OpenFL / Flixel but am struggling to understand what each one is for.
As I understand it:
Haxe is a language that can be deployed to multiple platforms. OpenFL is something to do with Flash. Flixel is a library to help you make games.
Could anyone correct me/make it clearer.
To quote from haxe.org:
Haxe is an open source toolkit based on a modern, high level, strictly typed programming language, a cross-compiler, a complete cross-platform standard library and ways to access each platform's native capabilities.
Language:
Haxe is a programming language. It's similar to AS3, C# etc. It is strictly typed, but has great type inference. It has a lot of powerful features such as Pattern Matching, Enums (ADTs), Macros etc. These work no matter which target you compile to.
Standard Library:
Haxe can compile to JavaScript, C++, Flash, Java, C#, PHP, Neko, HashLink, Python and Lua. It has low level standard classes that work consistently across platforms, such as: String
, Int
, Float
, Date
, Map
etc. It also has some useful cross platform code for things like Serialization, Xml
, Json
, Date
formatting etc.
As a general rule, anything on api.haxe.org that is in the top level, or in the haxe
package, is going to work whichever target you compile to.
Each target has its own package. These let you access native capabilities of that target via externs. Eg. js.html
has DOM externs, flash
has externs for the Flash API, etc.
There is the sys
package, which is available on "backend" targets: C++, Java, Neko, HashLink, PHP, Python and Lua. It's also available on JavaScript/Node with the hxnodejs library.
Other stuff:
The Haxe compiler is super fast compared to a bunch of other compilers. That's a selling point in itself. There's also macros, which let you do a bunch of pre-processing in a really powerful way. Then there's tools like Haxelib which let you link in with 3rd party libraries.
When Haxe first started, Flash was still a big target, it was installed everywhere, and it was great for making games. A lot of Flash developers liked Haxe because it was fast, type safe, open source, and gave them more features. But the flash API (sprites, graphics, movie clips, events) only worked on Flash, not on mobile, or on HTML5 etc. Which was a problem once flash started becoming less popular.
What OpenFL does is make that Flash API work on other Haxe targets. So you wrote a Haxe game targeting the flash API using sprites and graphics and flash-style code. Then, you want to compile to C++ (for targeting mobile etc). OpenFL lets your Haxe code use the Flash API, even if targeting C++ or JavaScript. For example, OpenFL creates the flash.graphics.DisplayObject
class not only for flash, but for C++ and JavaScript. So if you know how to write Flash games, you are close to writing OpenFL games already.
OpenFL also has some great tools for making it easier to deploy your games to specific platforms. Where Haxe targets are things like "JS", "SWF", "C++", OpenFL platforms are things like "iOS", "Android", "Switch", "HTML5", "Windows EXE" etc. When you hear about Haxe targeting mobile, a lot of the time it is OpenFL, because it works with Haxe to compile your code (into C++, JS, SWF or whatever) and then packages those binaries for mobile.
Haxe is a language, compiler and standard library.
OpenFL builds on this and adds the Flash API working across targets.
HaxeFlixel builds on this even further and provides game specific APIs that work on OpenFL.
An example of how it all works together:
You create a game. All of it is written in Haxe. Things like player name, scores, and completion info all use data structures from the standard library. They'll work in your game, but you could also make them work on your PHP website.
Your game uses OpenFL to compile to Flash, HTML5, iOS and Android. As part of OpenFL, you also have access to standard Flash API classes, like the Stage and Buttons and MouseEvents, which you might use for your menu screen. Because OpenFL provides the flash.* classes for other targets, your app compiles to all different things.
For your actual game, performance is important, and the flash DisplayList approach is a bit slow and not optimised for gaming. HaxeFlixel is optimised for gaming, and is very fast. So you design your game with HaxeFlixel using their APIs.
Haxe is a language, compiler, toolkit and standard library. It provides the most basic tools for cross-platform code.
OpenFL is built on Haxe, and provides the Flash API to multiple targets (Flash, C++, JavaScript) and makes it easy to compile to a bunch of platforms: web, native, iOS, Android, Nintendo Switch etc.
HaxeFlixel is built on OpenFL - it uses the APIs provided by OpenFL to create a game specific framework that is high performance and easy to make 2D games.