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

Spewing Particles Briefly for Explosions

We want to add explosions to the two collisions in our game: when the ship either shoots or collides with an obstacle. We’ll build these particle emitters the same way we built the thrust emitter. Adding them to the scene is easy, but we have a problem. We don’t want these emitters to keep running indefinitely. How do we make them die out and remove them from the scene after a short duration?

We use Sprite Kit actions, of course! Specifically, we’ll use an action sequence to pause for a short duration, and then set the particle birthrate property to zero and wait for all the particles to die before removing the node. Because this is such a common operation for our emitters in this game and we already ...

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