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

Exploring physics simulation mechanics


Let's take a closer look at the specifics of SpriteKit's physics system. For instance, why are the bees subject to gravity, but the ground stays where it is? Though we attached physics bodies to both nodes, we actually used two different styles of physics bodies. There are three types of physics bodies, and each behaves slightly differently:

  • Dynamic physics bodies have volume and are fully subject to forces and collisions in the system. We will use dynamic physics bodies for most parts of the game world: the player, enemies, power-ups, and others.

  • Static physics bodies have volume but no velocity. The physics simulation does not move nodes with static bodies but they can still collide with other game objects. We can use static bodies for walls or obstacles.

  • Edge physics bodies have no volume and the physics simulation will never move them. They mark off the boundaries of movement; other physics bodies will never cross them. Edges can cross each other...