FlxSnippet: Change font in all FlxText at once

Here’s a nice block of code to change the font for all the FlxText in a group / state, instead of manually calling setFormat on each one. ForEach exposes FlxBasic objects, but once we make sure the current iterable is a FlxText we can safely cast it and do our deed! Make sure to call before changing the alignment as setFormat will change it back to its default value. Tested in Haxeflixel 4.0
    if (Std.is(member, FlxText))
        cast(member, FlxText).setFormat(AssetPaths.YOUR_FONT__TTF);
}, true);

1 comment:

  1. si (Std.is (miembro, FlxText))
    yeso (miembro, FlxText) .setFormat (AssetPaths.YOUR_FONT__TTF);
    }, Verdadera );