Post not yet marked as solved
Post marked as unsolved with 1 replies, 339 views
my problem is that touchesBegan() is not called as I know it from other projects. Therefore there must be a difference somewhere to my other projects. Now I got the idea, that the following code prevents calling touchesBegan():In didMove():tapRec.addTarget(self, action:#selector(GameScene.tappedView(_:) ))
tapRec.numberOfTouchesRequired = 1
tapRec.numberOfTapsRequired = 1
self.view!.addGestureRecognizer(tapRec)The function:@objc func tappedView(_ sender:UITapGestureRecognizer) {
let point:CGPoint = sender.location(in: self.view)
print("single tap")
print(point)
}touchesBegan()override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
let locationUser = touch.location(in: self)
if self.atPoint(locationUser) == background {
print("background touch")
}
}
}I come to the idea that the above function tappedView() is to blame for not executing touchesBegan(), since this function is called when the screen is touched instead of touchesBegan().Is there a way to use both touchesBegan() and tappedView() without them blocking each other?Thank you in advance.