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"];
}
}
}
...
}
SKTextureoutside of theforloop (and then assign thenode2.textureto that texture? Would that be a better way? - Glidermanforloop; that's because its a spritenode. That is why I must make anotherforloop that accesses the sprite nodes. I have made an edit: It was supposed to beSKNode *node = [self nodeAtPoint: location];- Exprosul