Class reference

Parallax2D

Inherits Node2D

A node used to create a parallax scrolling background.

Description

A Parallax2D is used to create a parallax effect. It can move at a different speed relative to the camera movement using scroll_scale. This creates an illusion of depth in a 2D game. If manual scrolling is desired, the Camera2D position can be ignored with ignore_camera_scroll. Note: Any changes to this node's position made after it enters the scene tree will be overridden if ignore_camera_scroll is false or screen_offset is modified.

Properties

Vector2 autoscroll = Vector2(0, 0)

Velocity at which the offset scrolls automatically, in pixels per second.

bool ignore_camera_scroll = false

If true, Parallax2D's position is not affected by the position of the camera.

Vector2 limit_begin = Vector2(-10000000, -10000000)

Top-left limits for scrolling to begin. If the camera is outside of this limit, the Parallax2D stops scrolling. Must be lower than limit_end minus the viewport size to work.

Vector2 limit_end = Vector2(10000000, 10000000)

Bottom-right limits for scrolling to end. If the camera is outside of this limit, the Parallax2D will stop scrolling. Must be higher than limit_begin and the viewport size combined to work.

int physics_interpolation_mode = 2

Vector2 repeat_size = Vector2(0, 0)

Repeats the Texture2D of each of this node's children and offsets them by this value. When scrolling, the node's position loops, giving the illusion of an infinite scrolling background if the values are larger than the screen size. If an axis is set to 0, the Texture2D will not be repeated.

int repeat_times = 1

Overrides the amount of times the texture repeats. Each texture copy spreads evenly from the original by repeat_size. Useful for when zooming out with a camera.

Vector2 scroll_scale = Vector2(1, 1)

Multiplier to the final Parallax2D's offset. Can be used to simulate distance from the camera. For example, a value of 1 scrolls at the same speed as the camera. A value greater than 1 scrolls faster, making objects appear closer. Less than 1 scrolls slower, making objects appear further, and a value of 0 stops the objects completely.

Tutorials

Source revision 4f5b14abade2
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.