Learn HaxeFlixel from Scratch (pt. 2): Running the Latest Dev Code
Apparently HaxeFlixel is in the midst of some major rewriting. If you simply install it using
haxelib install haxeflixel, you get the latest tagged release, 2.0.0-alpha.3. However, the various demos actually depend on the latest dev code to run. I like to learn from demos and couldn’t handle being left in the dark, so here’s what I did to start running from “dev”, the latest versions of the code.
First, I uninstalled whatever HaxeFlixel related libraries I already had. At the time, they were flixel and flixel-addons. You can find yours by typing
haxelib list from the command line and then
haxelib remove <library> for each HaxeFlixel related library you find.
Second, I went to GitHub and forked the projects I wanted to download. I did this so I could actually install the dev versions of the libraries from my own repositories. This will make it easier for me to contribute back, because I’ll be able to make and test my changes locally before pushing them to my GitHub repository and submitting the changes to the main projects as pull requests.
For now, I just went with flixel and flixel-tools, and I recommend you do the same. Flixel Tools contains the command line interface tools that were previously available in the main Flixel library. You’ll need them to create a new template for a project or convert a HaxeFlixel 2.0.0-alpha.3 project to run on dev.
Next, I installed the libraries from my Git repositories using
haxelib git <library> <URL> <branch>. Run this once per library, substituting the library name (flixel or flixel-tools), the Git repository URL (copied from the GitHub page), and dev as the branch. Note that it’s perfectly fine to install from the main repositories instead of your own forks. If you do use a fork, you’ll be responsible for pulling in changes to your forks from the main repositories before running
haxelib upgrade to update your local copies to the latest dev code.
Finally, I wanted to create and test a new project from a template using the flixel-tools command line interface. First you have to instruct flixel-tools to download the template and demo files using
haxelib run flixel-tools download. Then you create a new directory for the project, switch to that directory, and execute
haxelib run flixel-tools template -n <name> -w <width> -h <height>.
To test this, you should be using openfl, a separate Haxe library. If you don’t have this already, there are download instructions using haxelib on the OpenFL getting started page. Once it’s installed and setup, you can test your new project with
openfl test <target>. I’m developing on OS X, so I use “mac -neko” as the target, though I don’t think there’s a difference if you just target “neko”.
Now that I’m all setup, I’m eager to continue learning both the language and the library. Not content to just use without giving back, I’ve already submitted my first pull request to the project to rename a couple misspelled variables. Onward!