ZoomToFit class
Settings for zooming the camera so that a whole TargetGroup stays in view while it is chased.
camera.chase(
players,
zoomToFit: const ZoomToFit(padding: 100, minZoom: 0.5),
);
The camera zooms towards the level at which the group plus padding on every side fits the viewport, kept between minZoom and maxZoom.
The fit is measured from where the camera actually is, not from the center of the group. So the targets stay in view even when an offset or a dead zone keeps the camera away from the center, or while the camera catches up with a fast group. The zoom is calculated as if the camera were not rotated.
Constructors
- ZoomToFit({double padding = 0, double minZoom = 0, double maxZoom = 1})
-
Creates zoom settings for chasing a TargetGroup.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxZoom → double
-
The highest zoom, which limits how far the camera zooms in while the
targets are close together. The default of
1keeps the normal zoom until the targets spread apart.final - minZoom → double
-
The lowest zoom, which limits how far the camera zooms out.
0means no limit.final - padding → double
-
Extra space in world units to keep around the outermost targets.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
zoomFor(
TargetGroup group, Vector2 cameraPosition, Vector2 viewportSize) → double? -
The zoom at which
groupplus padding fits a viewport ofviewportSizecentered oncameraPosition, kept between minZoom and maxZoom.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited