From 8775585f22d3cfb2d1e7f994ce4c4004bde8bf53 Mon Sep 17 00:00:00 2001 From: Metlmeta Date: Mon, 18 Apr 2022 11:29:58 -0400 Subject: [PATCH] Align FlxText between all targets 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. --- flixel/text/FlxText.hx | 6 ++++++ flixel/ui/FlxButton.hx | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/flixel/text/FlxText.hx b/flixel/text/FlxText.hx index 36c51d8a0f..eed5b99c65 100644 --- a/flixel/text/FlxText.hx +++ b/flixel/text/FlxText.hx @@ -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); diff --git a/flixel/ui/FlxButton.hx b/flixel/ui/FlxButton.hx index 388c20a1f4..67bf4a2fe9 100644 --- a/flixel/ui/FlxButton.hx +++ b/flixel/ui/FlxButton.hx @@ -57,7 +57,7 @@ class FlxButton extends FlxTypedButton 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); }