Skip to content
Download

Parallax background

  1. In the Layers panel, create a Background layer (Montanhas) and place it below the others.
  2. In the layer Inspector, pick the Sprite and check Repeat H.
  3. In an object of the level, move the layer according to the camera:
function onUpdate(self)
setLayerPosition("Montanhas", camera.x * 0.5, 40)
end
  • The factor goes from 0 (fixed to the level, no parallax) to 1 (fixed to the screen). The closer to 1, 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.