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

Physics


In other frameworks, you will most probably have to import a physics engine library of your choice, such as Box2d, or chipmunk would configure it to make it work properly. You would also have to write custom code for making collision detection work. In SpriteKit, every scene has physics running in the background as soon as the scene is created. You are not required to do anything else to make it work. So, in the gameplay scene, we will disable the physics engine we created and replace it with SpriteKit's inbuilt physics engine.

Open up the gameplayScene.swift file and comment out the updateHero function in the update function. As you might remember, the updateHero function took care of making the hero get affected by gravity, making sure the hero was inside the screen at all times and also making sure thrust is applied when the player taps the left half of the screen. Using the inbuilt physics engine, we will see how we can make it do all the work for us.

As I said earlier, the physics...