使粒子遵循spriteKit中的路径

问题描述:

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

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

我已将此粒子添加到场景中,制作了一个圆圈并强制粒子使用以下方法运行该圈:

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...

任何想法?

谢谢

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

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;