noloman
noloman

Reputation: 11965

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!

Upvotes: 13

Views: 8023

Answers (1)

Antonio MG
Antonio MG

Reputation: 20410

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

Upvotes: 22

Related Questions