For anyone stumbling upon this, I found a workaround that's a bit dirty but works. I had to create an updateRadioColor
function that is called in your FlxState
's update()
call (so the radio group has to be re-colored every update...seems a bit inefficient and unnecessary but I couldn't find another way).
Anyways, here's the class that uses setFormat
to adjust the text and some magic numbers based on my font size (36). You'll need to adjust it a bit for your use case.
package client;
import client.Common.Globals;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.addons.ui.FlxUIRadioGroup;
import flixel.addons.ui.StrNameLabel;
import flixel.group.FlxSpriteGroup;
import flixel.util.FlxColor;
import js.lib.webassembly.Global;
class RadioGroup extends FlxUIRadioGroup
{
public static inline var defaultWidth:Int = 400;
public static inline var defaultHeight:Int = 75;
public static inline var defaultLabelWidth:Int = 350;
public static inline var defaultYSpace:Int = 50;
public function new(x:Int, y:Int, ids:Array<String>, labels:Array<String>, ?width:Int = defaultWidth, ?height:Int = defaultHeight,
?labelWidth:Int = defaultLabelWidth, ?ySpace:Int = defaultYSpace)
{
super(x, y, ids, labels, updateCallback, ySpace, width, height, labelWidth);
updateRadioColor();
}
public function updateRadioColor()
{
for (checkBox in getRadios())
{
// magic numbers to place the text properly. If the font size changes, these will need to be adjusted
checkBox.button.label.x = checkBox.x + 20;
checkBox.button.label.y = checkBox.y - 17.5;
checkBox.button.label.setFormat(Globals.fontFamily, Globals.fontSize, FlxColor.BLACK, "left");
checkBox.button.scale.set(1, 2);
checkBox.button.offset.set(-50, -15);
checkBox.button.updateHitbox();
checkBox.box.scale.set(3, 3);
checkBox.mark.scale.set(3, 3);
}
}
public function updateCallback(id:String):Void {}
}