O'Reilly logo

Build iOS Games with Sprite Kit by Josh Smith, Jonathan Penn

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

Showing Puffs of Smoke When Hitting Targets and Bumpers

The particle emitters we added to Space Run were so much fun that we just can’t leave them out of our pinball game. We’re going to add little puffs of smoke everywhere the ball hits a target or bumper, but to make it look more realistic we need to figure out the angle of that puff.

That’s where the SKPhysicsContact object comes in. It exposes a contactPoint property that gives us the precise position of the collision between the two bodies in scene coordinates. Once we convert those coordinates into the table nodes coordinate system, then we can place quick particle emitters into the scene at that point. It also exposes the collisionImpulse property to tell us how hard the hit was. This ...

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