Add shortcut to SKSpriteNode without touching

How to disable interaction for a child node?

I add shortcuts to a bunch of sprites, under the sprite, describing what it is. The sprites themselves are tangible and have a code that responds when you touch Begun, etc.

Labels do not visually overlap the sprite, they are completely under the visual representation of the sprites, but they are the daughters of their corresponding sprite, and I would like to save it that way.

But I do not want the shortcuts to respond to touch.

I set the tags to

myLabel.isUserInteractionEnabled = false 

But it does not matter, they still react to touch, as if it is Sprite.

+7
touch sprite-kit sklabelnode
source share
1 answer

By default, isUserInteractionEnabled false , then touching a child, like SKLabelNode , is by default a simple touch to the main (or parent) class (the object exists here, but if you don't implement any action, just touch it)

If you set the userInteractionEnabled property to true on a SKNode subclass, then touch delegates will call inside that particular class. This way you can handle touching a label (as you would for your case) in your class.

+1
source share

All Articles