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

Introducing the cast


Strap on your hard hat, we are going to be writing a lot of code in this chapter. Stick with it! The results are well worth the effort. Meet the new cast of characters we will be introducing in this chapter:

Adding the power-up star

Many of my favorite games grant temporary invulnerability when the player picks up a star. We will add a hyperactive star power-up to our game. Meet our star:

Locating the art assets

You can find the art assets for power-up stars and coins inside the goods.atlas texture atlas in the Coins and Powerups folder of the assets bundle. Add the goods.atlas texture atlas to your project now.

Adding the Star class

Once the art is in place, you can create a new Swift file named Star.swift in your project; we will continue to organize classes into distinct files. The Star class will be similar to the Bee class we created earlier; it will inherit from SKSpriteNode and adhere to our GameSprite protocol. The star will add a lot of power to the player, so we...