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.json',
);
final animationComponent = SpriteAnimationComponent(200, 200, animation);
animationComponent.x = (size.x / 2) - 100;
animationComponent.y = (size.y / 2) - 100;
final animationComponent = SpriteAnimationComponent(200, 200, animation)
..setByPosition(size / 2 - Vector2(100, 100));
add(animationComponent);
}

View File

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