I have come across a problem where I'm having trouble deleting several SKEmitterNodes at different times. Each SKEmitterNode is created through an iteration, so they have different times for when to be deleted (they should be deleted after they have emitted all of their specified particles). This is what I currently have:
let explosionNode = SKEmitterNode(fileNamed: "Explosion.sks")
explosionNode?.position = missile.position
explosionNode?.numParticlesToEmit = 350
addChild(explosionNode!)
let nodesEmit = CGFloat((explosionNode?.numParticlesToEmit)!) / (explosionNode?.particleBirthRate)!
let seconds = nodesEmit + (explosionNode?.particleLifetime)! + (explosionNode?.particleLifetimeRange)! / 2
run(SKAction.sequence ([
SKAction.run(removeExplosion(node: explosionNode!)),
SKAction.wait(forDuration: TimeInterval(seconds)),
])
)
and the function is
func removeExplosion(node: SKEmitterNode) {
node.removeFromParent()
print("REMOVED")
}
However, I'm getting an error saying Cannot convert value of type '()' to expected argument type '() -> Void'. Is there anyway to run an SKAction with parameters or is there another way to delete SKEmitterNodes after they have finished emitting all their particles?