Use setByPosition instead of size.x/y

This commit is contained in:
Lukas Klingsbo
2020-09-16 21:09:50 +02:00
parent 0de63bebca
commit b5a0b3d675
2 changed files with 4 additions and 8 deletions

View File

@ -22,10 +22,8 @@ class MyGame extends BaseGame {
'chopper.png', 'chopper.png',
'chopper.json', 'chopper.json',
); );
final animationComponent = SpriteAnimationComponent(200, 200, animation); final animationComponent = SpriteAnimationComponent(200, 200, animation)
..setByPosition(size / 2 - Vector2(100, 100));
animationComponent.x = (size.x / 2) - 100;
animationComponent.y = (size.y / 2) - 100;
add(animationComponent); add(animationComponent);
} }

View File

@ -44,13 +44,11 @@ class MyGame extends BaseGame {
add(TextComponent('center', config: tiny) add(TextComponent('center', config: tiny)
..anchor = Anchor.center ..anchor = Anchor.center
..x = size.x / 2 ..setByPosition(size / 2));
..y = size.y / 2);
add(TextComponent('bottomRight', config: tiny) add(TextComponent('bottomRight', config: tiny)
..anchor = Anchor.bottomRight ..anchor = Anchor.bottomRight
..x = size.x ..setByPosition(size));
..y = size.y);
add(MyTextBox( add(MyTextBox(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eget ligula eu lectus lobortis condimentum.', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eget ligula eu lectus lobortis condimentum.',