feat!: Add CameraComponent to FlameGame (#2740)

This PR adds the `CameraComponent` and a `World` by default to the
FlameGame.
This commit is contained in:
Lukas Klingsbo
2023-09-18 21:06:37 +02:00
committed by GitHub
parent 5be6fc8cae
commit 7c2f400076
89 changed files with 1107 additions and 821 deletions

View File

@ -24,9 +24,6 @@ class EmberQuestGame extends FlameGame
double cloudSpeed = 0.0;
double objectSpeed = 0.0;
final world = World();
late final CameraComponent cameraComponent;
@override
Future<void> onLoad() async {
//debugMode = true; // Uncomment to see the bounding boxes
@ -39,9 +36,7 @@ class EmberQuestGame extends FlameGame
'star.png',
'water_enemy.png',
]);
cameraComponent = CameraComponent(world: world);
cameraComponent.viewfinder.anchor = Anchor.topLeft;
addAll([cameraComponent, world]);
camera.viewfinder.anchor = Anchor.topLeft;
initializeGame(loadHud: true);
}
@ -112,7 +107,7 @@ class EmberQuestGame extends FlameGame
);
world.add(_ember);
if (loadHud) {
cameraComponent.viewport.add(Hud());
camera.viewport.add(Hud());
}
}