ParallaxBackground
A node used to create a parallax scrolling background.
ParallaxBackground.swift:14class ParallaxBackground
A ParallaxBackground uses one or more ParallaxLayer
child nodes to create a parallax effect. Each ParallaxLayer
can move at a different speed using motionOffset
. This creates an illusion of depth in a 2D game. If not used with a Camera2D
, you must manually calculate the scrollOffset
.
Superclasses
class CanvasLayer
A node used for independent rendering of objects within a 2D scene.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var scrollBaseOffset: Vector2
The base position offset for all
ParallaxLayer
children.var scrollBaseScale: Vector2
The base motion scale for all
ParallaxLayer
children.var scrollIgnoreCameraZoom: Bool
If
true
, elements inParallaxLayer
child aren’t affected by the zoom level of the camera.var scrollLimitBegin: Vector2
Top-left limits for scrolling to begin. If the camera is outside of this limit, the background will stop scrolling. Must be lower than
scrollLimitEnd
to work.var scrollLimitEnd: Vector2
Bottom-right limits for scrolling to end. If the camera is outside of this limit, the background will stop scrolling. Must be higher than
scrollLimitBegin
to work.var scrollOffset: Vector2
The ParallaxBackground’s scroll value. Calculated automatically when using a
Camera2D
, but can be used to manually manage scrolling when no camera is present.