Improve default constructor for positioned components (#667)

This commit is contained in:
pedia
2021-02-24 00:27:17 +08:00
committed by GitHub
parent ec09ce0ce6
commit 9735cf5e08
11 changed files with 95 additions and 47 deletions

View File

@@ -20,9 +20,11 @@ class MyGame extends BaseGame {
jsonData,
);
final spriteSize = Vector2.all(200);
final animationComponent =
SpriteAnimationComponent.fromSpriteAnimation(spriteSize, animation)
..position = size / 2 - Vector2.all(100);
final animationComponent = SpriteAnimationComponent(
position: size / 2 - Vector2.all(100),
size: spriteSize,
animation: animation,
);
add(animationComponent);
}