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

@ -15,26 +15,18 @@ class ParticlesInteractiveExample extends FlameGame with PanDetector {
final random = Random();
final Tween<double> noise = Tween(begin: -1, end: 1);
final ColorTween colorTween;
final double zoom;
final world = World();
late final CameraComponent cameraComponent;
ParticlesInteractiveExample({
required Color from,
required Color to,
required this.zoom,
}) : colorTween = ColorTween(begin: from, end: to);
@override
Future<void> onLoad() async {
cameraComponent = CameraComponent.withFixedResolution(
world: world,
width: 400,
height: 600,
);
addAll([cameraComponent, world]);
cameraComponent.viewfinder.zoom = zoom;
}
required double zoom,
}) : colorTween = ColorTween(begin: from, end: to),
super(
camera: CameraComponent.withFixedResolution(
width: 400,
height: 600,
)..viewfinder.zoom = zoom,
);
@override
void onPanUpdate(DragUpdateInfo info) {