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!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With