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
this.forEach(function(member)
{
if (Std.is(member, FlxText))
cast(member, FlxText).setFormat(AssetPaths.YOUR_FONT__TTF);
}, true);