Book Image

Game Development with Swift

By : Stephen Haney
Book Image

Game Development with Swift

By: Stephen Haney

Overview of this book

Table of Contents (18 chapters)
Game Development with Swift
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Spawning endless encounters


We need at least three encounters to endlessly cycle and create a never-ending world; two can be on the screen at any one time and a third positioned ahead of the player. We can track Pierre's progress and reposition the encounter nodes ahead of him.

Building more encounters

We need to build at least two more encounters before we can implement the repositioning system. You can create more if you like; the system will support any number of encounters. For now, add two more scene files to your game: EncounterBees.sks and EncounterCoins.sks. You can completely fill these encounters with bees, ghosts, blades, coins, and bats – have fun!

For inspiration, here is my bee encounter:

Here is my coin encounter:

Updating the EncounterManager class

We have to let the EncounterManager class know about these new encounters. Open the EncounterManager.swift file and add the new encounter names to the encounterNames constant:

// Store your encounter file names:
let encounterNames:[String...