Chapter 9
Add More Scenes and Levels
Multiple Player Lives
Before you begin adding more levels to the game, you have some additional details to implement. For instance, you’ll want the player to be able to “die” more than once in the game without the game ending. You will have the game start with several player lives, so that when a nasty vermin bites the player, it can reappear a few seconds later, ready to tackle them again. After all, accidents happen and vermin are vicious and sewers are stinky, but your hero is resilient and will survive! Hopefully.
First you need to add a constant that will determine the number of lives with which the player starts each game. Add this line at the top of the SKBGameScene.h file:
#import "SKBRatz.h"
Get Learn Sprite Kit for iOS Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.