Rework AtlasText to use FunkinGroup

This commit is contained in:
AbnormalPoof
2026-04-06 04:18:08 -06:00
committed by Hundrec
parent a01b4ce4af
commit bc06e7fcc1
3 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ class FunkinGroup<T:FlxSprite> extends FlxSprite
/**
* The children of this FunkinGroup.
*/
public var children:Null<Array<T>>;
public var children:Array<T>;
/**
* The size of this FunkinGroup. Read only.
+1 -1
View File
@@ -906,7 +906,7 @@ class PauseSubState extends MusicBeatSubState
var text:AtlasText = new AtlasText(0, yPos, entry.text, AtlasFont.BOLD);
text.scrollFactor.set(0, 0);
text.alpha = 0;
for (letter in text)
for (letter in text.children)
{
letter.width *= 2;
letter.height *= 2;
+11 -11
View File
@@ -2,7 +2,7 @@ package funkin.ui;
import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import funkin.group.FunkinGroup;
import flixel.util.FlxStringUtil;
/**
@@ -10,7 +10,7 @@ import flixel.util.FlxStringUtil;
* It supports animations on the letters, and is less buggy than Alphabet.
*/
@:nullSafety
class AtlasText extends FlxTypedSpriteGroup<AtlasChar>
class AtlasText extends FunkinGroup<AtlasChar>
{
static var fonts:Map<AtlasFont, AtlasFontData> = new Map<AtlasFont, AtlasFontData>();
static var casesAllowed:Map<AtlasFont, Case> = new Map<AtlasFont, Case>();
@@ -60,7 +60,7 @@ class AtlasText extends FlxTypedSpriteGroup<AtlasChar>
value = caseValue;
group.kill();
this.kill();
if (value == "") return this.text;
@@ -101,16 +101,16 @@ class AtlasText extends FlxTypedSpriteGroup<AtlasChar>
*/
function appendTextCased(str:String):Void
{
var charCount:Int = group.countLiving();
var charCount:Int = countLiving();
var xPos:Float = 0;
var yPos:Float = 0;
// `countLiving` returns -1 if group is empty
if (charCount == -1) charCount = 0;
else if (charCount > 0)
{
var lastChar:AtlasChar = group.members[charCount - 1];
xPos = lastChar.x + lastChar.width - x;
yPos = lastChar.y + lastChar.height - maxHeight - y;
var lastChar:AtlasChar = children[charCount - 1];
xPos = lastChar.localX + lastChar.width - x;
yPos = lastChar.localY + lastChar.height - maxHeight - y;
}
for (splitStr in str.split(""))
@@ -124,16 +124,16 @@ class AtlasText extends FlxTypedSpriteGroup<AtlasChar>
yPos += maxHeight;
case char:
var charSprite:AtlasChar;
if (group.members.length <= charCount) charSprite = new AtlasChar(atlas, char);
if (children.length <= charCount) charSprite = new AtlasChar(atlas, char);
else
{
charSprite = group.members[charCount];
charSprite = children[charCount];
charSprite.revive();
charSprite.char = char;
charSprite.alpha = 1; // gets multiplied when added
}
charSprite.x = xPos;
charSprite.y = yPos + maxHeight - charSprite.height;
charSprite.localX = xPos;
charSprite.localY = yPos + maxHeight - charSprite.height;
add(charSprite);
xPos += charSprite.width;