Making a particle follow a path in spriteKit
Asked Answered
F

1

17

I have created a particle and when I test it moving on Xcode's property window, it looks like this:

enter image description here

I have added this particle to a scene, made a circle and forced the particle to run that circle using this:

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

    CGPathRef circle = CGPathCreateWithEllipseInRect(CGRectMake(0,0,400,400), NULL);

    SKAction *followTrack = [SKAction followPath:circle asOffset:NO orientToPath:YES duration:1.0];

    SKAction *forever = [SKAction repeatActionForever:followTrack];

    [myParticle runAction:forever];

This is how it looks like. Like a block of white sugar candy. The node particle is following the path, but not the generated particles.

I have represented a circle in dashed so you can see the path it is following...

enter image description here

Any ideas?

thanks

Fluorocarbon answered 24/9, 2013 at 15:39 Comment(2)
if anyone gets stuck, try adding myParticle.targetNode = self;Hyperpyrexia
Hi @SpaceDog, mind to help me please? #29383041Upbuild
C
13

You sent the particle emitter to follow the path. If you want individual particles to run an action, use the emitter's particleAction property:

myParticle.particleAction = forever;
Cavalierly answered 24/9, 2013 at 16:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.