O'Reilly logo

iOS Game Programming Cookbook by Bhanu Birani, Chhavi Vaishnav

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting contact and collisions

We apply physics simulation to the bodies by adding the SKPhysicsBody function to a node. While the scene processes each frame, it performs all the physics-related calculations for all the bodies in the scene. It also calculates all the custom forces that are applied on any body in the scene, which eventually gives the realistic effects in the game. Collision detection is an important part while developing any game in the real world because in almost all games we check for the collision of two bodies. For example, in any warfare game, we may need to check whether a bullet has collided with the player.

Getting ready

There are various shapes for the physics bodies that can be used to apply physics to a scene. These ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required