For example, I have a Color Sprite object wich can move and bounce at the wall. How can i make it disappear when I catch it and touch it on the screen?
you have to set a name for your sprite like "ballNode", then in "touchesBegan" function you can handle it.
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in (touches) {
let positionInScene = touch.location(in: self)
let touchedNode = self.atPoint(positionInScene)
if let name = touchedNode.name {
if name == "ballNode" {
//make it hidden by touchedNode.isHidden = true
//or remove it from parent by touchedNode.removeFromParent()
}
}
}
}