I have a SKEmitterNode
and I'm trying to stop it when a button is pressed. I add my node in this way:
let followLine = SKAction.followPath(border.CGPath, asOffset: false, orientToPath: true, duration: 2.0)
let loopAction = SKAction.repeatActionForever(followLine)
emitterNode.targetNode = scene
emitterNode.runAction(loopAction, withKey: "loop")
addChild(emitterNode)
I add the emitterNode to my SKScene
and when I want to stop the particles I tried all these possible ways:
let action = SKAction.runBlock { [weak self] in
self?.emitterNode.particleBirthRate = 0
}
emitterNode.runAction(action)
emitterNode.removeAllActions()
emitterNode.removeFromParent()
removeAllActions()
let remove = SKAction.removeFromParent()
emitterNode.removeActionForKey("loop")
emitterNode.runAction(remove)
The emitter doesn't stop and the animation continues.