2016-06-28 37 views
1

我正在研究类似于this video tutorial中所述的以SpriteKit/Swift 2.2为目标的iOS 9.3的类爆炸粒子系统。为什么工作粒子系统只有一次?

我(简化)代码:

let emiExplode = SKEmitterNode(fileNamed: "ExplosionParticleSystem.sks") 

private func initEmitters() { 
    emiExplode?.particleBirthRate = 0.0 
    emiExplode?.targetNode = scene 
    emiExplode?.zPosition = 1 
    scene.addChild(emiExplode!) 
} 

private func explode() { 
    emiExplode?.position = self.position 
    emiExplode?.particleBirthRate = 2000.0 
    // remove explosion particle system shortly after 
    let action = SKAction.sequence([SKAction.waitForDuration(1.5), 
            SKAction.runBlock({ self.emiExplode?.particleBirthRate = 0 })]) 
    emiExplode?.runAction(action) 
} 

我第一次打电话爆炸()它就像一个魅力。但第二次,粒子效应是不可见的...

任何想法?

回答

0

我同时找到解决方案:

self.emiExplode?.resetSimulation() 

...做的伎俩。