Question

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!

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top