Reading the actual sources you will find:
open var isUserInteractionEnabled: Bool
but this applies to internal node touch methods. By default, isUserInteractionEnabled false , then touching a child similar to your SKSpriteNode overlay is by default a simple touch to the main (or parent) class (the object exists here, but if you do not perform any actions, just touch it)
To go through the overlay with a touch, you can implement code like the one below to your GameScene . Repeat also do not use -1 as zPosition , because it means that it is below your scene.
PS . I added name for sprites to call it on touchesBegan , but you can create global variables in GameScene :
override func sceneDidLoad() { // Creat touchable let touchable = TouchableSprite(circleOfRadius: 100) touchable.zPosition = 0 touchable.fillColor = SKColor.red touchable.isUserInteractionEnabled = true touchable.name = "touchable" addChild(touchable) // Create overlay let overlayNode = SKSpriteNode(imageNamed: "fade") overlayNode.zPosition = 1 overlayNode.name = "overlayNode" overlayNode.isUserInteractionEnabled = false addChild(overlayNode) } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { print("GameScene Touch began") for t in touches { let touchLocation = t.location(in: self) if let overlay = self.childNode(withName: "//overlayNode") as? SKSpriteNode { if overlay.contains(touchLocation) { print("overlay touched") if let touchable = self.childNode(withName: "//touchable") as? TouchableSprite { if touchable.contains(touchLocation) { touchable.touchesBegan(touches, with: event) } } } } } } }
Alessandro ornano
source share