mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
feat!: Add CameraComponent to FlameGame (#2740)
This PR adds the `CameraComponent` and a `World` by default to the FlameGame.
This commit is contained in:
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user