I currently display particle effects once my sprite collides with another sprite in-game.
I have this snippet of code:
let sparkParticle = SKEmitterNode(fileNamed: "SparkParticle.sks")
if sparkParticle.parent == nil
{
sparkParticle.position = mySprite.position
self._particleLayer.addChild(sparkParticle)
}
sparkParticle.resetSimulation()
The particle I created has a birthrate of 1000 particles with a maximum of 100. I set the position of the particle emitter node to where my sprite is currently on screen. Then, I add it as a child of the particle layer node.
My question is, do I have to manually remove the particle emitter node from its parent after it's finished? Or does Sprite Kit automatically remove it after it has finished playing?
Since my project is designed to have the sprites collide with each other a lot, I want to make sure if I still need to handle this manually to prevent memory leaks (the particle layer having a lot of child emitter nodes that are finished playing already)