Skip to content

Commit

Permalink
Align FlxText between all targets (#2536)
Browse files Browse the repository at this point in the history
The desktop and mobile versions of FlxText do not render in the same visual location as web, instead rendering +1 x/y from the origin.

Separately, the code for centering text on a button has always used (x - 1, y +3), even as far back as 2013. Changes to text (possibly through OpenFL) have improved centering and no longer need the (x - 1), which currently causes it to render off-center.
  • Loading branch information
Metlmeta committed Apr 18, 2022
1 parent 68d26b2 commit 0e712ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions flixel/text/FlxText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,12 @@ class FlxText extends FlxSprite

return;
}
#elseif !web
// Fix to render desktop and mobile text in the same visual location as web
_matrix.translate(-1, -1); // left and up
graphic.draw(textField, _matrix);
_matrix.translate(1, 1); // return to center
return;
#end

graphic.draw(textField, _matrix);
Expand Down
2 changes: 1 addition & 1 deletion flixel/ui/FlxButton.hx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class FlxButton extends FlxTypedButton<FlxText>
super(X, Y, OnClick);

for (point in labelOffsets)
point.set(point.x - 1, point.y + 3);
point.set(point.x, point.y + 3);

initLabel(Text);
}
Expand Down

0 comments on commit 0e712ed

Please sign in to comment.