71 Squared Blog

Sprite Kit Particle System

Posted by Tom Bradley on Sunday, February 1st, 2015

Source Code: https://github.com/71squared/ParticleEmitterDemo-SK

Ever since the introduction of Sprite Kit and it’s particle system we have been trying to figure out a way to support it in Particle Designer. On the face of it this seems like a simple problem to solve. Unfortunately this is far from the truth.

The Theory

The theory was simple. Create a class that implements our core particle system logic and for each frame, applies the calculated values to an array of SKSpriteNode objects.

The Easy Bit

I quickly hacked together a Sprite Kit project to see if the theory works. In no time at all I had some of our particle systems running in Sprite Kit. However is wasn’t without its issues.

The Tricky Bit

Performance. Making this thing rock took a little more tweaking than expected. The key to Sprite Kit is doing as little creation/destruction as possible. So I shifted around a bunch of code and re-wrote a few bits. The result is a particle system running at almost the same speed as Apples build in particle system. Yeehaw!

The Impossible Bit

And this is where the real let down comes in. Apple in all their wisdom have severely restricted the blending modes available to Sprite Kit developer. I understand that Sprite Kit has been built with simplicity in mind, and OpenGL blending modes can get confusing. But would it really have been that confusing to expose an override to allow for more advanced effects? Probably not.

The Conclusion

What we end up with is a particle system fully working in Sprite Kit that is compatible with Particle Designer. Except, when you design an effect in Particle Designer you’ll most likely end up with something looking quite different on your device. This is just unacceptable and so we are just unable to add Sprite Kit as a supported framework at this time.

That being said, we are happy to put the code into the wild in the hope that someone has also come across this very problem and been able to solve it.

If you fancy having a play, feel free to take a look at the code.


If you have any thoughts or suggestions, we’d love to hear from you.