HaxeFlixel 5.9.0

After 8 long months since 5.8.0, I'm happy to announce the largest Flixel release since I've taken over as lead. We don't like to go that far without releases, but new things just kept piling on. To name a few, we have:

When will Flixel 6 be released?

The next release will be version 6.0.0, unless for some reason an urgent patch is needed for 5.9.0. For the current list of changes in Flixel 6, look here. Many devs are using 6.0.0 already, and you can too! Just run:

haxelib git flixel https://github.com/HaxeFlixel/flixel.git release6

If you have been compiling with no-deprecation-warnings in your project's build command, now is the time to fix all of those, otherwise your project will not compile in Flixel 6. I also recommend using a haxe version of 4.3 or higher, which allows Flixel to suppress various internal deprecation warnings that were left in for backwards compatibility. If you have any issues with any of this don't hesitate to let me know, either in github or the Haxe discord's Flixel channel.

New and improved FlxInputText

Special thanks to Starmapo for completely redoing FlxInputText from the ground up! New features include:

Check out these features in the new FlxInputText Demo

With the addition of InputTextFrontEnd, which controls the text input events used to power FlxInputText, creating other text inputs will be much easier, expect a FlxBitmapInputText, soon!

AssetFrontEnd

If you're sick of doing sprite.loadGraphic(Paths.image("hero")), well, you're in luck! FlxG.assets, is the new customizable interface that takes string asset paths and gives the desired assets. by setting the following dynamic method:

public dynamic function getAssetUnsafe(id:String, type:FlxAssetType, useCache = true):Null<Any>
HX

Here are just a few neat uses for this:

Simplifying asset paths

The above example that loads the hero sprite can be simplified to sprite.loadGraphic("hero"), like so:

// Edit the simplified id before passing it to the old method
function path(id:String, type:FlxAssetType)
{
  // for flixel assets, just pass them to the old method
  if (StringTools.startsWith(id, "flixel/") || StringTools.contains(id, ':'))
    return id;

  return switch type
  {
    case BINARY: 'assets/data/$id'; // expects extension already'
    case TEXT  : 'assets/data/$id.json';
    case IMAGE : 'assets/images/$id.png';
    case SOUND : 'assets/sounds/$id.ogg';
    case FONT  : 'assets/font/$id.ttf';
  };
}

final assets = FlxG.assets;

// Save the old methods, call them with the full path
final oldExists = assets.exists;
assets.exists = (id, ?type)->oldExists(path(id, type ?? BINARY), type);

final oldIsLocal = assets.isLocal;
assets.isLocal = (id, ?type, cache = true)->oldIsLocal(path(id, type ?? BINARY), type, cache);

final oldGet = assets.getAssetUnsafe;
assets.getAssetUnsafe = (id, type, cache = true)->oldGet(path(id, type), type, cache);
HX

Hot-Reloading

Sick of building the game just to see some asset change in the game? Simply add the following flag to your build command, and the compiled game will look at the source assets whenever it's run:

-DFLX_CUSTOM_ASSETS_DIRECTORY="assets"

Not only will this save time on dev builds in projects with many assets, but you can modify assets and see them in your game without recompiling.

Automatically append sound file extensions

Define flag -DFLX_DEFAULT_SOUND_EXT="ogg" to allow sound asset ids to omit the extension. Useful when targeting multiple platforms that use different sound files. Can also use the flag to determine the desired sound extension, setting the flags value to "mp3" "wav" or "ogg" will use that extension. The default extension can be read via FlxG.assets.defaultSoundExtension

Collision, Tilemaps and Tiles, Oh my!

Plenty of improvements, features and helpers have been added. Let's go over a few

FlxTiles

FlxTilemaps

We also broke apart Flixel's collision tools into smaller parts that can be used to customize the collision of any FlxObject.

Misc shout outs

For more updates, follow HaxeFlixel on BlueSky or check us out on Github and Discord!