I am making a game with Sprite Kit. When there is a collision I would like to retrieve the image of the SKSpriteNode that my projectile collided with to assign different point values depending on the image of the monster. I think comparing the texture property of the SKSpriteNode could work. I have tried the following code, but my if statement is never called. Any suggestions?
- (void)projectile:(SKSpriteNode *)projectile didCollideWithMonster:(SKSpriteNode *)monster {
SKTexture *tex = [SKTexture textureWithImageNamed:@"img.png"];
if ([[monster texture] isEqual:tex])
{
NSLog(@"it works");
}
}
Yes, there is a way to compare two images/textures using UIImage.