BonfireCamera class

Available Extensions

Constructors

BonfireCamera(CameraConfig config)

Properties

angle double
getter/setter pair
cameraRect Rect
no setter
cameraRectWithSpacing Rect
no setter
canvasSize Vector2
no setterinherited
combinedProjector → Projector
no setterinherited
defaultShakeDuration double
getter/setter pairinherited
defaultShakeIntensity double
getter/setter pairinherited
follow Vector2?
If set, the camera will "follow" this vector, making sure that this vector is always rendered in a fixed position in the screen, by immediately moving the camera to "focus" on the where the vector is.
getter/setter pairinherited
gameRef BonfireGame
getter/setter pair
gameSize Vector2
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isMoving bool
no setter
moveOnlyMapArea bool
getter/setter pair
position Vector2
This is the current position of the camera, ie the world coordinate that is rendered on the top left of the screen (origin of the screen space).
no setterinherited
relativeOffset Vector2
Where in the screen the follow object should be.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shaking bool
Whether the camera is currently shaking or not.
no setterinherited
sizeMovementWindow Vector2
getter/setter pair
smoothCameraEnabled bool
getter/setter pair
speed double
getter/setter pairinherited
target GameComponent?
getter/setter pair
viewport ↔ Viewport
getter/setter pairinherited
worldBounds Rect?
If set, this determines boundaries for the camera movement.
getter/setter pairinherited
zoom double
If set, the camera will zoom by this ratio. This can be greater than 1 (zoom in) or smaller (zoom out), but should always be greater than zero.
getter/setter pairinherited

Methods

absoluteTarget() Vector2
This is the (current) absolute target of the camera, i.e., the coordinate that should with relativeOffset taken into consideration but regardless of world boundaries or shake.
inherited
animateLoopRotation({required List<double> angles, required int repeatCount, bool normalizeOnFinish = true, List<Duration>? pauseDuration, List<Duration>? rotationDuration, List<Curve>? curves, VoidCallback? onFinish}) → void
animateSimpleRotation({required double angle, Duration? duration, VoidCallback? onFinish, Curve curve = Curves.decelerate}) → void
animateZoom({required double zoom, Duration? duration, VoidCallback? finish, Curve curve = Curves.decelerate}) → void
apply(Canvas canvas) → void
Use this method to transform the canvas using the current rules provided by this camera object.
inherited
contains(Offset c) bool
followComponent(PositionComponent component, {Anchor relativeOffset = Anchor.center, Rect? worldBounds}) → void
Immediately snaps the camera to start following the component.
followVector2(Vector2 vector2, {Anchor relativeOffset = Anchor.center, Rect? worldBounds}) → void
Immediately snaps the camera to start following vector2.
handleResize(Vector2 canvasSize) → void
inherited
isComponentOnCamera(GameComponent c) bool
isRectOnCamera(Rect c) bool
moveDown(double displacement) → void
moveRight(double displacement) → void
moveTo(Vector2 position) → void
Applies an ad-hoc movement to the camera towards the target, bypassing follow. Once it arrives the camera will not move until resetMovement is called.
inherited
moveTop(double displacement) → void
moveToPlayer() → void
moveToPlayerAnimated({Duration? duration, VoidCallback? finish, double? zoom, double? angle, Curve curve = Curves.decelerate}) → void
moveToPosition(Vector2 position) → void
moveToPositionAnimated(Vector2 position, {double? zoom, double? angle, VoidCallback? finish, Duration? duration, Curve curve = Curves.decelerate}) → void
moveToTarget(GameComponent? target) → void
moveToTargetAnimated(GameComponent target, {double? zoom, double? angle, VoidCallback? finish, Duration? duration, Curve curve = Curves.decelerate}) → void
moveUp(double displacement) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onPositionUpdate(Vector2 position) → void
If you need updated on when the position of the camera is updated you can override this.
inherited
projectVector(Vector2 worldCoordinates) Vector2
Converts a vector in the world space to the screen space.
inherited
resetMovement() → void
Smoothly resets any moveTo targets.
inherited
scaleVector(Vector2 worldCoordinates) Vector2
Converts a vector representing a delta in the world space to the screen space.
inherited
screenToWorld(Vector2 screenCoordinates) Vector2
Takes coordinates in the screen space and returns their counter-part in the world space.
inherited
setRelativeOffset(Anchor newRelativeOffset) → void
This will trigger a smooth transition to a new relative offset.
inherited
shake({double? duration, double? intensity}) → void
Applies a shaking effect to the camera for duration seconds and with intensity expressed in pixels.
inherited
snap() → void
Use this to immediately "snap" the camera to where it should be right now. This bypasses any currently smooth transitions and might be janky, but can be used to setup after a new world transition for example.
inherited
snapTo(Vector2 position) → void
Instantly moves the camera to the target, bypassing follow. This will replace any previous targets.
inherited
toString() String
A string representation of this object.
inherited
translateBy(Vector2 displacement) → void
Moves the camera by a given displacement (delta). This is the same as moveTo but instead of providing an absolute end position, you can provide a desired translation vector.
inherited
unprojectVector(Vector2 screenCoordinates) Vector2
Converts a vector in the screen space to the world space.
inherited
unscaleVector(Vector2 screenCoordinates) Vector2
Converts a vector representing a delta in the screen space to the world space.
inherited
update(double dt) → void
This smoothly updates the camera for an amount of time dt.
updateSpacingVisibleMap(double space) → void
worldToScreen(Vector2 worldCoordinates) Vector2
Takes coordinates in the world space and returns their counter-part in the screen space.
inherited

Operators

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