Parallax background

When travelling by train, mountains in the distance seem to be static, but trees and grass next to the track move very fast. In 2D games, a similar effect is simulated by a parallax background. It adds a feeling of depth to the game. A parallax background contains a few layers. The player is usually in the front, but there can be a layer in front of the player as well. This simulates objects that are closer to the camera.

When the camera moves, the layers in the back are scrolled slowly and the layers in front are scrolled faster; the same as in our train example.

In platformers, we often use a static background with a few parallax layers. It's a good idea to make the background less prominent and less distracting, but nevertheless ...

Get Learning AndEngine now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.