From cdbdf864d9dcc1c81146ce4da7f3526d72fae31a Mon Sep 17 00:00:00 2001 From: Luan Nico Date: Sat, 30 Sep 2023 13:10:22 -0400 Subject: [PATCH 1/2] fix: Fix TextBoxComponent alignment bug --- packages/flame/lib/src/components/text_box_component.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flame/lib/src/components/text_box_component.dart b/packages/flame/lib/src/components/text_box_component.dart index 83cf80b9fe2..643e712164f 100644 --- a/packages/flame/lib/src/components/text_box_component.dart +++ b/packages/flame/lib/src/components/text_box_component.dart @@ -282,7 +282,7 @@ class TextBoxComponent extends TextComponent { (boxHeight - nLines * _lineHeight) * align.y + i * _lineHeight, ); - textElement.render(canvas, position, anchor: anchor); + textElement.render(canvas, position); charCount += lines[i].length; } From 4881f5746e5519a6fe6975fb36fabd802b89eeec Mon Sep 17 00:00:00 2001 From: Luan Nico Date: Sat, 30 Sep 2023 13:24:39 -0400 Subject: [PATCH 2/2] Add a test --- packages/flame/test/components/text_box_component_test.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/flame/test/components/text_box_component_test.dart b/packages/flame/test/components/text_box_component_test.dart index a3ebeb17609..ce5b98d6627 100644 --- a/packages/flame/test/components/text_box_component_test.dart +++ b/packages/flame/test/components/text_box_component_test.dart @@ -163,9 +163,10 @@ void main() { _FramedTextBox( text: 'That shows thee a weak slave; for the weakest goes to the ' 'wall.', - position: Vector2(410, 320), + position: Vector2(410, 320) + Vector2(380, 270), size: Vector2(380, 270), align: Anchor.centerRight, + anchor: Anchor.bottomRight, ), ]); }, @@ -194,6 +195,7 @@ class _FramedTextBox extends TextBoxComponent { super.align, super.position, super.size, + super.anchor, }) : super( textRenderer: DebugTextRenderer(fontSize: 22), );