Update game.md (#1127)

* Update game.md

fixed the load error for the readme docs.

* Update game.md

* Update doc/game.md

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
This commit is contained in:
dbilgin
2021-11-20 01:28:19 +01:00
committed by GitHub
parent 0dfe97ce42
commit 0aacb607a4

View File

@ -28,14 +28,17 @@ class MyCrate extends SpriteComponent {
@override
void onGameResize(Vector2 gameSize) {
// We don't need to set the position in the constructor, we can it directly here since it will
super.onGameResize(gameSize);
// We don't need to set the position in the constructor, we can set it directly here since it will
// be called once before the first time it is rendered.
position = gameSize / 2;
}
}
class MyGame extends FlameGame {
MyGame() {
@override
Future<void> onLoad() async {
await super.onLoad();
add(MyCrate());
}
}