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

Chapter 3. Mix in the Physics

SpriteKit includes a fully functional physics engine. It is easy to implement and very useful; most mobile game designs require some level of physical interaction between game objects. In our game, we want to know when the player runs into the ground, an enemy, or a power-up. The physics system can track these collisions and execute our specific game code when any of these events occur. SpriteKit's physics engine can also apply gravity to the world, bounce and spin colliding sprites against each other, and create realistic movement through impulses – and it does all of this before every single frame is drawn to the screen.

The topics in this chapter include:

  • Adopting a protocol for consistency

  • Organizing game objects into classes

  • Adding the player's character

  • Renovating the GameScene class

  • Physics bodies and gravity

  • Exploring physics simulation mechanics

  • Movement with impulses and forces

  • Bumping bees into bees