O'Reilly logo

Learning Swift: Building an iOS Game by Jocelyn Harrigton, Christoffer Hallas, Clayton McIlrath, Paul Nettle, Ankur Patel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Adding our hero life line

After learning how to create a level in the previous chapter, it is time to add a life line to our hero that slowly depletes overtime. In the game, our hero can die in a few ways. He can fall off the platform and hit the ground, go off the screen, collide with certain obstacles like TNT, or just run out of his life line. Because our hero is a pencil he will need to collect as many sharpeners as he can to increase his life line. The life line will be displayed on the top right hand corner of the screen. The goal is to reach the finish line before you run out of lead and not hit the ground. Let’s see how to achieve this.

We will discuss the following Swift concepts in this chapter:

  • Convenience initializers ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required