Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix TextBoxComponent alignment bug #2781

Merged
merged 2 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/flame/lib/src/components/text_box_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class TextBoxComponent<T extends TextRenderer> extends TextComponent {
(boxHeight - nLines * _lineHeight) * align.y +
i * _lineHeight,
);
textElement.render(canvas, position, anchor: anchor);
textElement.render(canvas, position);

charCount += lines[i].length;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/flame/test/components/text_box_component_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed this would have broken on current main

size: Vector2(380, 270),
align: Anchor.centerRight,
anchor: Anchor.bottomRight,
),
]);
},
Expand Down Expand Up @@ -194,6 +195,7 @@ class _FramedTextBox extends TextBoxComponent {
super.align,
super.position,
super.size,
super.anchor,
}) : super(
textRenderer: DebugTextRenderer(fontSize: 22),
);
Expand Down