i need to check if my sprite node texture is equal to name @"GoldDot". i try the code
if ([red.texture isEqual:@"GoldDot"]) {
NSLog(@"gold!!!!");
}else{
}
please help
To compare SKTextures, have a look at this answer.
A cleaner alternative would be to set the name of the SKSpriteNode as the image you are setting.
NSString *textureName = @"GoldDot";
SKSpriteNode *node =[SKSpriteNode spriteNodeWithImageNamed: textureName];
node.name = textureName;
Afterwards, just compare the name
if ([red.name isEqual:@"GoldDot"]) {
NSLog(@"gold!!!!");
}