Book Image

iOS Game Programming Cookbook

Book Image

iOS Game Programming Cookbook

Overview of this book

Table of Contents (19 chapters)
iOS Game Programming Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Parallax background


Now our mini game FlyingSpaceship is about to finish. To give the feel of a game environment we will introduce a parallax scrolling background. A parallax scrolling background is composed of multiple background layers (that is, nodes); animating them simultaneously gives a feel of dynamic background. To add some cool flyers to the game we will add two layers of background: the SpaceBlueSky and the SpaceWhiteMist in the form of nodes.

Getting ready

To start with this cool feature, we should be aware of the scrolling background created in the previous chapter and have a basic knowledge of sprites, nodes, and math. We are going to cook the Parallax background recipe in the FlyingSpaceship game.

How to do it…

To create multiple scrolling backgrounds with varying speeds of scrolling, we will be creating a class for it to accomplish the parallax background. The steps involved in creating a class for parallax background named as FSParallaxNode are as follows:

  1. Create a new file by...