我正在使用针对 iOS 9.3 的 SpriteKit/Swift 2.2 开发类似爆炸的粒子系统,如 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() 时,它就像一个魅力。但是第二次,粒子效果不可见...
有什么想法吗?
最佳答案
同时我找到了解决方案:
self.emiExplode?.resetSimulation()
...成功了。
关于ios - 为什么粒子系统只工作一次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38085146/