Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add particles using SpriteKit in iOS7

I'd like to add a particle to my SpriteKit app, but I can't find how to do it. I'm able to create using the particle editor, but how do I add them to my view?

Thanks a lot in advance!

like image 684
noloman Avatar asked Sep 19 '13 09:09

noloman


1 Answers

Lets say that you have a particle already created called MyParticle.sks.

First, you have to create a SKEmitterNode with your particle:

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

Now that the node is created, you can edit some parameters if you want:

    myParticle.particlePosition = CGPointMake(100, 100);
    myParticle.particleBirthRate = 5;

And the add it to your scene:

[self addChild:myParticle];

This has to be added to your SKScene

like image 124
Antonio MG Avatar answered Oct 02 '22 05:10

Antonio MG