I have a btnPause
that is a SKSpriteNode
and this node added two children:
let pauseOrange = SKShapeNode(circleOfRadius: 12)
...
let pauseX = SKSpriteNode(imageNamed: "close")
...
btnPause.addChild(pauseOrange)
btnPause.addChild(pauseX)
self.addChild(btnPause)
where btnPause
has the same size and position as its pauseOrange
and pauseX
.
But, with the parent node, it doesn't print anything in the functiontouchesBegan
if node == self.btnPause { print("btnPause")}
instead with its content if it works in the functiontouchesBegan
if node == self.pauseOrange { print("pauseOrange")}
Is there a way that if I touch the container of the nodes, it (the container) will take the event in the function touchesBegan
?
What I want to achieve is that when pressing any child node, it is as if they pressed the parent node, thus saving me from doing many ORs in the IF of the functiontouchesBegan
One possible solution is to create a transparent node with the same size as the parent node, which should be on top of all child nodes, so if they click that node, it means they wanted to click the parent node or any child node.