mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
Use setByPosition instead of size.x/y
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
@ -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.',
|
||||
|
||||
Reference in New Issue
Block a user