CameraComponent.withFixedResolution constructor
CameraComponent.withFixedResolution({
- required double width,
- required double height,
- World? world,
- Viewfinder? viewfinder,
- Component? backdrop,
- List<
Component> ? hudComponents, - ComponentKey? key,
Create a camera that shows a portion of the game world of fixed size
width
x height
.
The viewport will be centered within the canvas, expanding as much as
possible on all sides while maintaining the width
:height
aspect ratio.
The zoom level will be set such in such a way that exactly width
x
height
pixels are visible within the viewport. The viewfinder will be
initially set up to show world coordinates (0, 0) at the center of the
viewport.
Implementation
CameraComponent.withFixedResolution({
required double width,
required double height,
World? world,
Viewfinder? viewfinder,
Component? backdrop,
List<Component>? hudComponents,
ComponentKey? key,
}) : this(
world: world,
viewport: FixedResolutionViewport(resolution: Vector2(width, height)),
viewfinder: viewfinder ?? Viewfinder(),
backdrop: backdrop,
hudComponents: hudComponents,
key: key,
);