4

I have a number of SKSpriteNodes with SKLabelNodes as children. What I would like is for any touch within the bounds of the sprite node to be handled by the sprite node, and for its children (the label nodes) to completely ignore touches. I tried doing this:

SKLabelNode *miles = [SKLabelNode labelNodeWithFontNamed:@"Verdana"];
miles.userInteractionEnabled = NO;

But this does not work. The label nodes register touches when I set this property to NO. Next I tried subclassing the label nodes and setting userInterationEnabled = NO in the init, as such:

@implementation BBLabelNode

-(id)init {
    if (self = [super init]) {

        self.userInteractionEnabled = NO;

    }
    return self;
}

@end

Sadly, this also did not work. So I am left wondering: how does one properly go about causing a label note to not receive touches at all?

zeeple
  • 5,509
  • 12
  • 43
  • 71
  • I would log out the description of the object receiving the touch in touchesBegan to see what the actual object is. It's possible that something else is reacting to the touch, not the Label Node. – Ben Kane Apr 01 '14 at 18:29
  • Can you show how you're detecting these touches? Also, have you seen this? It might help: https://github.com/iSofTom/STSpriteKit/blob/master/STSpriteKit/SKScene%2BSTAdditions.m – Mick MacCallum Apr 01 '14 at 18:42

1 Answers1

0

Only SKScene has userInteractionEnabled set to YES by default. So there is no need to set userInteractionEnabled to NO on your objects if you never enabled them.

Double check if something else, an object, node, scene, etc. is setting your label's userInteractionEnabled to YES.

Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143
  • I find that a very interesting suggestion. I can tell you I am familiar with all of the code and I know that nothing in the code ever sets that property to YES for any label node I create. Are you suggesting something could be setting them to YES behind the scenes? – zeeple Apr 02 '14 at 04:06