I have an SKSpriteNode and I want to change the texture on it when the user touches the screen. But cannot work out how to do so.
Creating and adding the head. (Declared in header).
head = [SKSpriteNode spriteNodeWithImageNamed:[NSString stringWithFormat:@"%@",face]];
head.position = CGPointMake(size.width / 2, size.height / 2);
[self addChild:head];
When a touch is detected, the below is run, but I cannot work out how to apply it to the SKSpritenode?!
SKAction* changeFace = [SKAction setTexture:[SKTexture textureWithImageNamed:[NSString stringWithFormat:@"%@",face]]];
[self runAction:changeFace];
I have tried the below also, but it does not seem to work...
head.texture = [SKTexture textureWithImageNamed:[NSString stringWithFormat:@"%@",face]];
Hope somebody is able to point me in the correct direction!