Closed saturnxxi closed 10 years ago
Have you set the name property first? I only ask because I have used the name property and it is persistent and functions normally with methods like childNodeWithName:
I am using it like this: BMGlyphLabel* startButtonLabel = [BMGlyphLabel labelWithText:@"PLAY" font:font]; startButtonLabel.name = @"startGame"; NSLog(@"%@", startButtonLabel.name); // Output is startGame Later in touchesBegan UITouch* touch = [touches anyObject]; CGPoint loc = [touch locationInNode:self]; SKNode* node = [self nodeAtPoint:loc]; NSLog(@"%@", node.name); if ([node.name isEqualToString:@"startGame"]) { // start the game }
// Output is NULL
What am i doing wrong?
I would guess that the node found at that point is not the startButtonLabel. Node at point returns the deepest node at the given location. https://developer.apple.com/library/ios/documentation/SpriteKit/Reference/SKNode_Ref/Reference/Reference.html#//apple_ref/occ/instm/SKNode/nodeAtPoint:
BMGlyphLabel uses child nodes for each letter so you are probably finding one those instead.
I think we can close this issue...
hint for saturn: use one of the following
It is not possible to get the name of the node. All the time null is returned.