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

Adding infinite scrolling


Now we are all ready with our spaceship. It's time to add some more in the game. So our next target is to add infinite scrolling to the game, so that we can make our spaceship move infinitely in space. In this recipe, we will be learning about the ways to add infinite scrolling to games.

Getting ready

For an infinite scrolling background you need to know about the anatomy of SpriteKit shown earlier. You should be aware of the rendering loop, how in a particular frame the update method functions, and how SKScene evaluates the actions and physics simulation thereby rendering all the stuff in the SKView. Now using this loop, you implement sky scrolling infinitely giving the feel of a spaceship flying.

How to do it...

Now is the time for action; perform the following steps to add the infinite scrolling background to your game.

  1. Import the SpaceBackground.png file provided in the Resources folder.

  2. Add a function in FSMyScene for initializing the infinite background.

  3. In order...