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
| ||
| ||
| ||
| ||
| ||
physics_interpolation_mode |
| |
| ||
| ||
| ||
| ||
|
Property Descriptions
Vector2autoscroll =Vector2(0,0)
🔗
Vector2get_autoscroll()
Velocity at which the offset scrolls automatically, in pixels per second.
boolget_follow_viewport()
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
🔗
boolis_ignore_camera_scroll()
Iftrue
,Parallax2D's position is not affected by the position of the camera.
Vector2limit_begin =Vector2(-1e+07,-1e+07)
🔗
Vector2get_limit_begin()
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)
🔗
Vector2get_limit_end()
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)
🔗
Vector2get_repeat_size()
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.
intget_repeat_times()
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)
🔗
Vector2get_screen_offset()
Offset used to scroll thisParallax2D. This value is updated automatically unlessignore_camera_scroll istrue
.
Vector2scroll_offset =Vector2(0,0)
🔗
Vector2get_scroll_offset()
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)
🔗
Vector2get_scroll_scale()
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.