Search code examples
iphoneios7sprite-kit

iOS firework explosion using Sprite Kit particles


I'm implementing app for kids activities and I want to add celebration animation such a fireworks:

enter image description here

any of you knows this be implemented using Sprite Kit particles or if is another option please let me know.

I'll really appreciate your help.


Solution

  • This can easily be done using the Particle Emitter Editor, which I advise you to read about here.


    Here's my set up to get a similar effect:

    1. first off we need to create a SpriteKite Particle File

    right click project -> new file - > SpriteKit Particle File enter image description here

    1. Next select Particle Template -> Spark

    2. To load this file use this (objective-c):

      SKEmitterNode *emitter = [NSKeyedUnarchiver unarchiveObjectWithFile:[[NSBundle mainBundle] pathForResource:@"MyParticle" ofType:@"sks"]];

    Now to do complex things like remove from sky, you'll have to change the life time of the emitter. Again read the Apple docs.


    For those who keep coming back to this question (and then down voted it because I didn't show you what my side bar configurations looked like) here's an example of what could be your firework set up.

    SpriteKit Firework example

    Here's an example of what it looks like in action (with the above config):

    enter image description here