I’ll start with I’m new to swift and Xcode, as well as stack overflow so forgive me if I break some rules. I have a button in my gamescene and I’m trying to call a function when it is click. I’ve tried 2 things which I’ll add here. Nothing online has been helpful. I used the sprite kit, the button is a spritenode that doesn’t have its Own class. Any help would be appreciated
func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch: AnyObject in touches {
let location = touch.location(in:self)
if attackBut.contains(_:location) {
player.texture = playF2
punc(dude: player, texts: playaFrames)
}
}
/*
let touch = touches.first
if let location = touch?.location(in: self) {
let nodesArray = self.nodes(at: location)
if nodesArray.first?.name == "attackBut" {
player.run(teste)
punc(dude: player, texts: playaFrames)
}
}
*/
}
The commented section is another method I tried.
I’m also on my phone so formatting may be weird. Thank you!