我正在开发一个类似爆炸的粒子系统,其SpriteKit / Swift 2.2针对iOS 9.3,如this video tutorial中所述。
我的(简化)代码:
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)
}
我第一次调用explode()就像魅力一样。但第二次,粒子效应是不可见的......
有什么想法吗?
答案 0 :(得分:0)
我同时找到了解决方案:
self.emiExplode?.resetSimulation()
......做了伎俩。