Reputation: 23
I would like to create the rocket spawn for space game with override func touchesbegan is spritekit. But the rocket will only spawn if the specific part of the screen is touched(f.e. image), not the whole screen.
Upvotes: 0
Views: 450
Reputation: 16327
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let area = CGRect(x: 0, y: 0, width: 100, height: 100)
guard let point = touches.first?.location(in: view),
area.contains(point) else {
return
}
//Spawn Logic Here
}
Upvotes: 1