使粒子遵循spriteKit中的路径

时间:2013-09-24 15:39:30

标签: ios iphone ipad sprite-kit skemitternode

我创建了一个粒子,当我在Xcode的属性窗口上测试它时,它看起来像这样:

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

有什么想法吗?

感谢

1 个答案:

答案 0 :(得分:14)

您已发送粒子发射器以跟踪路径。如果您希望单个粒子运行动作,请使用发射器的particleAction属性:

myParticle.particleAction = forever;
相关问题