Change node.name inside of touch without running again?

Viewed 58

I want to click on a certain spritenode and change the value of that spritenode. Here is the problem. When i do that, and set a if statement it knows to go to that if statement. However, i don't want it to run until next time the button is clicked.

Example:

apple.name = "apple"

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    for touch in touches {
        let location = touch.location(in: self)
        let node : SKNode = self.atPoint(location)
        if node.name == "apple" {
            appple.name = "orange" 
            print("Hello")
        }
        if node.name = "orange" {
        //do this
}

    }
}

Is there a way to do this?

1 Answers
Related