I was wondering if there was a more efficient way to changing the property of a SKSpriteNode
in touchesBegan
than my current method. The following is my method:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInNode:self]; SKNode *node = [self nodeAtPoint:location]; if ([node.name isEqualToString:@"Start"]){ for (SKSpriteNode *node2 in [self children]){ if ([node2.name isEqualToString:@"Start"]){ node2.texture = [SKTexture textureWithImageNamed:@"button_beige_pressed"]; } } } ... }
SKTexture
outside of thefor
loop (and then assign thenode2.texture
to that texture? Would that be a better way? – Glidermanfor
loop; that's because its a spritenode. That is why I must make anotherfor
loop that accesses the sprite nodes. I have made an edit: It was supposed to beSKNode *node = [self nodeAtPoint: location];
– Exprosul