O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition by Siddharth Shekar

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

Adding the parallax effect

In this section, we will add a parallax or scrolling background. This is a very popular effect in games, in which the objects in the foreground move faster as compared to the objects in the background that move much slower, giving the illusion of depth and motion.

Getting ready

Recall the movies of yesteryear in which the hero or subject remains stationary and acts as if they are galloping on a horse, and the background is looped to give the illusion that the hero is actually moving forward in the scene.

Getting ready

We will implement a very simple parallax effect in which all the objects in the background, such as the trees, bushes, ...

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