Added getWidth

This commit is contained in:
FlooferLand! 2024-07-01 14:44:23 +03:00
parent 488fc6888f
commit be5e0aafeb

View file

@ -152,6 +152,32 @@ class AtlasText extends FlxTypedSpriteGroup<AtlasChar>
}
}
public function getWidth():Int
{
var width = 0;
for (char in this.text.split(""))
{
switch (char)
{
case " ":
{
width += 40;
}
case "\n":
{}
case char:
{
var sprite = new AtlasChar(atlas, char);
sprite.revive();
sprite.char = char;
sprite.alpha = 1;
width += Std.int(sprite.width);
}
}
}
return width;
}
override function toString()
{
return "InputItem, " + FlxStringUtil.getDebugString([