3
我想單擊某個spritenode並更改該spritenode的值。這是問題。當我這樣做,並設置一個if語句,它知道要去那個if語句。但是,我不希望它在下次單擊該按鈕時運行。在觸摸裏面改變node.name而不再運行?
例子:
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
}
}
}
有沒有辦法做到這一點?