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.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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.',
|
||||||
|
|||||||
Reference in New Issue
Block a user