2013-09-24 51 views
17

的路径,当我测试它移动的Xcode的属性窗口,它看起来像这样:使粒子跟随我创建了一个粒子在spriteKit

enter image description here

我加入这个粒子场景,做了一个圆圈,并迫使粒子运行该圆:

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]; 

这就是它的样子。就像一块白糖糖。节点粒子跟随路径,但不是生成的粒子。

我曾代表破灭,所以你可以看到它是沿着路径了一圈......

enter image description here

任何想法?

感谢

+3

如果有人卡住了,请尝试添加myParticle.targetNode = self; – DogCoffee

+0

嗨@SpaceDog,介意帮助我吗? http://stackoverflow.com/questions/29382541/couldnt-make-a-particle-follow-a-path-in-spritekit – user1872384

回答

14

您发送的颗粒发射走的一条路。如果您希望单个粒子运行某个操作,请使用发射器的particleAction属性:

myParticle.particleAction = forever; 
+1

ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh我错过了!谢谢!!!!!!!!!! – SpaceDog