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 ...
Get Build iOS Games with Sprite Kit now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.