Parallax2D

Inherits:Node2D<CanvasItem<Node<Object

A node used to create a parallax scrolling background.

Description

AParallax2D is used to create a parallax effect. It can move at a different speed relative to the camera movement usingscroll_scale. This creates an illusion of depth in a 2D game. If manual scrolling is desired, theCamera2D position can be ignored withignore_camera_scroll.

Note: Any changes to this node's position made after it enters the scene tree will be overridden ifignore_camera_scroll isfalse orscreen_offset is modified.

Tutorials

Properties

Vector2

autoscroll

Vector2(0,0)

bool

follow_viewport

true

bool

ignore_camera_scroll

false

Vector2

limit_begin

Vector2(-1e+07,-1e+07)

Vector2

limit_end

Vector2(1e+07,1e+07)

PhysicsInterpolationMode

physics_interpolation_mode

2 (overridesNode)

Vector2

repeat_size

Vector2(0,0)

int

repeat_times

1

Vector2

screen_offset

Vector2(0,0)

Vector2

scroll_offset

Vector2(0,0)

Vector2

scroll_scale

Vector2(1,1)


Property Descriptions

Vector2autoscroll =Vector2(0,0)🔗

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


boolfollow_viewport =true🔗

Iftrue, thisParallax2D is offset by the current camera's position. If theParallax2D is in aCanvasLayer separate from the current camera, it may be desired to match the value withCanvasLayer.follow_viewport_enabled.


boolignore_camera_scroll =false🔗

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


Vector2limit_begin =Vector2(-1e+07,-1e+07)🔗

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


Vector2limit_end =Vector2(1e+07,1e+07)🔗

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


Vector2repeat_size =Vector2(0,0)🔗

Repeats theTexture2D 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 to0, theTexture2D will not be repeated.


intrepeat_times =1🔗

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


Vector2screen_offset =Vector2(0,0)🔗

Offset used to scroll thisParallax2D. This value is updated automatically unlessignore_camera_scroll istrue.


Vector2scroll_offset =Vector2(0,0)🔗

TheParallax2D's offset. Similar toscreen_offset andNode2D.position, but will not be overridden.

Note: Values will loop ifrepeat_size is set higher than0.


Vector2scroll_scale =Vector2(1,1)🔗

Multiplier to the finalParallax2D's offset. Can be used to simulate distance from the camera.

For example, a value of1 scrolls at the same speed as the camera. A value greater than1 scrolls faster, making objects appear closer. Less than1 scrolls slower, making objects appear further, and a value of0 stops the objects completely.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.