Camera class

Camera class for controlling the viewport

The camera determines what part of the world is visible and how it's displayed.

Constructors

Camera({Offset position = Offset.zero, double zoom = 1.0, double rotation = 0.0, Size viewportSize = Size.zero, double minZoom = 0.1, double maxZoom = 10.0, bool smoothing = false, double smoothingFactor = 0.1})
Create a camera

Properties

hashCode int
The hash code for this object.
no setterinherited
maxZoom double
Maximum zoom level
getter/setter pair
minZoom double
Minimum zoom level
getter/setter pair
position Offset
Camera position in world space
getter/setter pair
rotation double
Rotation in radians
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
smoothing bool
Whether to smooth camera movement
getter/setter pair
smoothingFactor double
Smoothing factor (0.0 - 1.0, higher = smoother but more lag)
getter/setter pair
viewportSize Size
Viewport size (set by rendering engine)
getter/setter pair
zoom double
Zoom level (1.0 = normal, >1.0 = zoom in, <1.0 = zoom out)
getter/setter pair

Methods

applyTransform(Canvas canvas, Size size) → void
Apply camera transform to canvas
follow(Offset target, {Offset? deadZone, bool smooth = true}) → void
Follow a target with optional dead zone
getVisibleBounds() Rect
Get the visible world bounds
isVisible(Offset point) bool
Check if a point is visible
lookAt(Offset target, {bool smooth = false}) → void
Look at a specific point
moveBy(Offset delta) → void
Move the camera by an offset
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Reset camera to default values
screenToWorld(Offset screenPos) Offset
Convert screen coordinates to world coordinates
setPosition(Offset newPosition, {bool smooth = false}) → void
Set the camera position
setZoom(double newZoom, {bool smooth = false}) → void
Set the camera zoom
shake(double intensity, double duration) → void
Shake the camera
toString() String
A string representation of this object.
inherited
update(double deltaTime) → void
Update camera (for smooth movement)
worldToScreen(Offset worldPos) Offset
Convert world coordinates to screen coordinates
zoomBy(double factor) → void
Zoom by a factor

Operators

operator ==(Object other) bool
The equality operator.
inherited