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.
- Import the
SpaceBackground.png
file provided in theResources
folder. - Add a function in
FSMyScene
for initializing the infinite background. - In...