Book Image

Learning iOS 8 Game Development Using Swift

By : Siddharth Shekar
Book Image

Learning iOS 8 Game Development Using Swift

By: Siddharth Shekar

Overview of this book

<p>Game development has been simplified with Apple's new programming language—Swift. If you're looking to start learning iOS development then you'll get everything you need - from&nbsp;the absolute basics such as the Xcode interface and takes you all the way to Swift programming.</p> <p>You will take a walk through the creation of 2D and 3D games followed by an introduction to SpriteKit and SceneKit. The book also looks at how game objects are placed in 3D scenes, how to use the graphics pipeline, and how objects are displayed on mobile screens. You will also delve into essential game concepts such as collision detection, animation, particle systems, and scene transitions. Finally, you will learn how to publish and distribute games to the iTunes store.</p>
Table of Contents (18 chapters)
Learning iOS 8 Game Development Using Swift
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Adding sound effects


As I mentioned earlier, adding sounds and effects in SpriteKit is very simple. It is really one line of code that needs to be added to create the desired sound effect.

First, we will import all the files to the project. So, select all the .mp3 files in the folder you created earlier, and drag them into the project.

Make sure that you check Copy items if needed and your project is selected as the target.

Also, make sure that the files exist under Copy Bundle Resources in the Build Phases, as the files sometimes don't get copied, even after you select the project as the target. If the files don't exist here, then you will get a build error saying the said file can't be found, even though the file exits in the project hierarchy. In that case, click on the + button and add the files.

Adding the fireRocket sound effect

Okay! With all the files imported, let's call the fireRocket sound effect whenever the hero fires a rocket. At the end of the addRockets function in the GamePlayScene...