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

@ -17,20 +17,21 @@ class RotateEffectExample extends FlameGame {
add small amounts of wobble, creating quasi-chaotic movement.
''';
final world = World();
late final CameraComponent cameraComponent;
RotateEffectExample()
: super(
camera: CameraComponent.withFixedResolution(
width: 400,
height: 600,
)..viewfinder.anchor = Anchor.topLeft,
world: _RotateEffectWorld(),
);
}
class _RotateEffectWorld extends World {
@override
void onLoad() {
cameraComponent = CameraComponent.withFixedResolution(
world: world,
width: 400,
height: 600,
);
addAll([cameraComponent, world]);
final compass = Compass(size: 200);
world.add(compass);
add(compass);
compass.rim.add(
RotateEffect.by(