Detect Touch event from a SKSpriteNode Parent

0

I have a btnPause that is a SKSpriteNode and to this node I 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 of its pauseOrange and pauseX .

But, with the parent node, it does not print anything in the function touchesBegan

if node == self.btnPause { print("btnPause")}

instead with its content if it works in the function touchesBegan

if node == self.pauseOrange { print("pauseOrange")}

Is there any way that if I touch the container of the nodes, this (the container) takes the event in the function touchesBegan ?

What I want to achieve is that by pressing any child node, it is as if the parent node were pressed, thus saving me from doing many ORs in the IF of the function touchesBegan

    
asked by albertcito 19.02.2016 в 23:43
source

1 answer

0

One possible solution is to create a transparent node with the same size as the parent node, which must be on all the child nodes, so if you press that node, they mean they wanted to press the parent node or any child node.

    
answered by 21.02.2016 / 06:02
source