O'Reilly logo

Swift 3 Game Development - Second Edition by Stephen Haney

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parallax background layers

Parallax adds the feeling of depth to your game by drawing separate background layers and moving them past the camera at varying speeds. Very slow backgrounds give the illusion of distance, while fast moving backgrounds appear to be close to the player. We can enhance the effect by painting faraway objects with increasingly desaturated colors.

In our game, we will achieve the parallax effect by attaching our backgrounds to the scene, then slowly pushing the backgrounds to the right as the camera pans right. As the camera moves to the right (making the children of the scene appear to move left), we will move the background's x position to the right, so that the total background node movement is less than for the other ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required