Parallax
namespace Griff.Scenes;
public sealed class Parallax : ComponentMakes a background layer scroll slower than the world as the camera moves, for depth: far hills at 0.2, near trees at 0.7. Everything the entity and its children draw shifts with it. With RepeatX or RepeatY, its sprite repeats to fill the view, so a short strip of sky or hills never runs out.
Applied when the game is drawn, so it never changes the entity’s transform: colliders, buttons and the Scene view all use where the transform puts it. The layer is drawn exactly there when the camera is at the world’s origin.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”Factor
Section titled “Factor”public Vector2 Factor { get; set; }How much the layer moves with the world on X and Y: 1 like everything else, 0 stuck to the camera (a distant sky), and in between for layers further back.
RepeatX
Section titled “RepeatX”public bool RepeatX { get; set; }Repeats the entity’s sprite side by side to fill the view’s width.
RepeatY
Section titled “RepeatY”public bool RepeatY { get; set; }Repeats the entity’s sprite top to bottom to fill the view’s height.
Methods
Section titled “Methods”OffsetFor
Section titled “OffsetFor”public Vector2 OffsetFor(Vector2 camera)How far the layer is shifted when seen from a camera at camera.