Parallax background
- In the Layers panel, create a Background layer (
Montanhas) and place it below the others. - In the layer Inspector, pick the Sprite and check Repeat
H. - In an object of the level, move the layer according to the camera:
function onUpdate(self) setLayerPosition("Montanhas", camera.x * 0.5, 40)endvoid onUpdate() override { setLayerPosition("Montanhas", scene().camera.x * 0.5f, 40);}- The factor goes from
0(fixed to the level, no parallax) to1(fixed to the screen). The closer to1, the more distant the layer looks. - Clouds that drift by themselves need no code: Speed in X, in the Background layer Inspector.
Reference: Layers and tiles, Camera.
