ParallaxBackground
A node used to create a parallax scrolling background.
A node used to create a parallax scrolling background.
A ParallaxBackground uses one or more ParallaxLayer child nodes to create a parallax effect. Each ParallaxLayer can move at a different speed using ParallaxLayer.MotionOffset. This creates an illusion of depth in a 2D game. If not used with a Camera2D, you must manually calculate the ParallaxBackground.ScrollOffset.
Note: Each ParallaxBackground is drawn on one specific Viewport and cannot be shared between multiple Viewports, see CanvasLayer.CustomViewport. When using multiple Viewports, for example in a split-screen game, you need create an individual ParallaxBackground for each Viewport you want it to be drawn on.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
ParallaxBackgroundConstructor
public ParallaxBackground();Properties6
ScrollBaseOffsetProperty
public Vector2 ScrollBaseOffset { get; set; }The base position offset for all ParallaxLayer children.
ScrollBaseScaleProperty
public Vector2 ScrollBaseScale { get; set; }The base motion scale for all ParallaxLayer children.
ScrollIgnoreCameraZoomProperty
public bool ScrollIgnoreCameraZoom { get; set; }If true, elements in ParallaxLayer child aren't affected by the zoom level of the camera.
ScrollLimitBeginProperty
public Vector2 ScrollLimitBegin { get; set; }Top-left limits for scrolling to begin. If the camera is outside of this limit, the background will stop scrolling. Must be lower than ParallaxBackground.ScrollLimitEnd to work.
ScrollLimitEndProperty
public Vector2 ScrollLimitEnd { get; set; }Bottom-right limits for scrolling to end. If the camera is outside of this limit, the background will stop scrolling. Must be higher than ParallaxBackground.ScrollLimitBegin to work.
ScrollOffsetProperty
public Vector2 ScrollOffset { get; set; }The ParallaxBackground's scroll value. Calculated automatically when using a Camera2D, but can be used to manually manage scrolling when no camera is present.
Methods12
GetLimitBeginVector2
public Vector2 GetLimitBegin();Vector2GetLimitEndVector2
public Vector2 GetLimitEnd();Vector2GetScrollBaseOffsetVector2
public Vector2 GetScrollBaseOffset();Vector2GetScrollBaseScaleVector2
public Vector2 GetScrollBaseScale();Vector2GetScrollOffsetVector2
public Vector2 GetScrollOffset();Vector2IsIgnoreCameraZoombool
public bool IsIgnoreCameraZoom();boolSetIgnoreCameraZoomvoid
public void SetIgnoreCameraZoom(bool ignore);| Name | Type | Default |
|---|---|---|
ignore | bool | — |
SetLimitBeginvoid
public void SetLimitBegin(Vector2 offset);| Name | Type | Default |
|---|---|---|
offset | Vector2 | — |
SetLimitEndvoid
public void SetLimitEnd(Vector2 offset);| Name | Type | Default |
|---|---|---|
offset | Vector2 | — |
SetScrollBaseOffsetvoid
public void SetScrollBaseOffset(Vector2 offset);| Name | Type | Default |
|---|---|---|
offset | Vector2 | — |
SetScrollBaseScalevoid
public void SetScrollBaseScale(Vector2 scale);| Name | Type | Default |
|---|---|---|
scale | Vector2 | — |
SetScrollOffsetvoid
public void SetScrollOffset(Vector2 offset);| Name | Type | Default |
|---|---|---|
offset | Vector2 | — |