In Swift and SpriteKit, you can designate an object as "isUserInteractionEnabled=false". Confusingly, this does not mean that the object will ignore touches and let those touches pass through to nodes below it.
The way I built SpriteKit apps it is very common for me to create a node (like a SKShapeNode or an SKSpriteNode) and then slap a label on it. What I want is for the label to ignore touches and let those touches pass through to the node behind it but I am failing to understand how this is done, if "isUserInteractionEnable" is not the ticket.
Any suggestions? Here is a sample label that receives touches but should not:
class MenuButton: SKShapeNode {
/* The MenuBar will have as children nine buttons of two types. Dialog Springers and SubMenu Droppers */
// MARK: - Class Variables
var title = "Button"
var menu = SKShapeNode()
let buttonLabel = SKLabelNode(fontNamed: devFont4)
init(title: String)
{
super.init()
isUserInteractionEnabled = true
self.title = title
self.name = "\(title) Menu Button"
let btnLen = title.count * 10 + 16
let menuSize = CGSize(width: btnLen, height: 32)
menu = SKShapeNode(rectOf: menuSize)
addChild(menu)
menu.fillColor = .clear
menu.strokeColor = .clear
menu.lineWidth = 0
menu.zPosition = 501
// Add Label
let letterHeight: CGFloat = 22
buttonLabel.text = title
buttonLabel.name = "\(title) Label"
buttonLabel.fontSize = letterHeight
buttonLabel.fontColor = .black
buttonLabel.zPosition = 502
buttonLabel.position = CGPoint(x: 0, y: Int(-letterHeight/2) + 2)
buttonLabel.isUserInteractionEnabled = false
addChild(buttonLabel)
}
}