Parallax
A background layer that moves at a fraction of the camera's own motion, so distant art drifts slower than the room and reads as further away.
On this page
Add it
+ Add node → Parallax creates a node with it already on. Already have a node for it? Add component → ParallaxComponent.
From a script
A script on the same node writes these fields by name. ParallaxComponent is the name to pass.
rgs
set_point("ParallaxComponent", "factor", vec2(0.5, 0.5));
set_point("ParallaxComponent", "offset", vec2(0.0, 0.0));
set_point("ParallaxComponent", "autoscroll", vec2(0.0, 0.0));
set_colour("ParallaxComponent", "color", vec4(1.0, 1.0, 1.0, 1.0));
set_flag("ParallaxComponent", "repeat_x", true);
set_flag("ParallaxComponent", "repeat_y", false);
set_point("ParallaxComponent", "repeat_period", vec2(0.0, 0.0)); Fields
| Field | Script name | Kind | Default | What it does |
|---|---|---|---|---|
| Factor | factor | two numbers (x, y), 0 to 1, step 0.01 | (0.5, 0.5) | How much of the camera's own motion this layer is carried along by, per axis. |
| Offset | offset | two numbers (x, y) | (0, 0) | A constant shift applied on top of the parallax scrolling. |
| Autoscroll | autoscroll | two numbers (x, y) | (0, 0) | World units per second this layer drifts on its own. |
| Color | color | colour | #ffffff | Tint applied to everything drawn under this layer; a light keeps its own colour. |
| Repeat X | repeat_x | checkbox | on | Repeat horizontally so the layer never runs out: its sprites and tilemaps are copied, and everything else under it is drawn once. |
| Repeat Y | repeat_y | checkbox | off | Repeat vertically, for a shaft or a well the camera falls down: its sprites and tilemaps are copied, and everything else under it is drawn once. |
| Repeat Period | repeat_period | two numbers (x, y), at least 0 | (0, 0) | With Repeat X or Y on, how far apart the whole layer's copies sit. At zero, each sprite is copied by its own size and each tilemap by the area its painted tiles cover. |