I have this function and I want to remove it once the game is over. I tried using removeActionWithKey but that doesn't seem to work. Is there another way I could remove it once the game is over?
func doAction() {
let generateCircles = SKAction.sequence([
SKAction.runBlock(self.circleRandom),
SKAction.waitForDuration(1.5)])
let endlessAction = SKAction.repeatActionForever(generateCircles)
runAction(endlessAction)
}
if firstBody.categoryBitMask == HeroCategory && secondBody.categoryBitMask == RedCategory {
//Tried to remove the func here but that doesn't work.
removeActionForKey("stop")
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
touchingScreen = false
if let touch = touches.first {
let location = touch.locationInNode(self)
let node = self.nodeAtPoint(location)
if node.name == "start" {
startGame.removeFromParent()
//Calling the doAction func here once start button is pressed.
let action = SKAction.runBlock(doAction)
runAction(action, withKey: "stop")
}
}
}