随着SKEmitterNode的进行,我的节点数量不断上升,我遇到了问题。我将 particleLifetime 和 numParticlesToEmit 设置为低。但是,它们似乎并没有被删除。我附加了一些图像,显示粒子开始时场景的节点数。
我看了一个使用火焰发射器的人的教程,结果表明,在粒子寿命结束后,节点数量正在减少。他们没有从场景中移除的另一个证据是我的记忆力在上升并且没有变平。如果有人可以帮助我或给我一些指导,我将非常感谢:)非常感谢!
func releaseParticles(location: CGPoint) {
// SKEmitterNode(s)
particleEmitterBlastUp = SKEmitterNode(fileNamed: "ParticleBlast")
particleEmitterBlastLeft = SKEmitterNode(fileNamed: "ParticleBlast")
particleEmitterBlastRight = SKEmitterNode(fileNamed: "ParticleBlast")
//If: the SkEmitters are valid
if let particlesUp = particleEmitterBlastUp,
let particlesLeft = particleEmitterBlastLeft,
let particlesRight = particleEmitterBlastRight {
//Setup SKEmitters
particlesLeft.numParticlesToEmit = 2
particlesLeft.particleLifetime = 2
particlesLeft.xScale = 0.23
particlesLeft.yScale = 0.23
particlesLeft.zPosition = -1.99
particlesLeft.position.x = location.x
particlesLeft.position.y = location.y + (20)
particlesLeft.xAcceleration = -300
//Add to: the scene
self.addChild(particlesLeft)
particlesRight.numParticlesToEmit = 2
particlesRight.particleLifetime = 2
particlesRight.xScale = 0.23
particlesRight.yScale = 0.23
particlesRight.zPosition = -1.99
particlesRight.position.x = location.x
particlesRight.position.y = location.y + (20)
particlesRight.xAcceleration = 300
//Add to: the scene
self.addChild(particlesRight)
}
}