How to compare SKSpriteNode textures

前端 未结 1 1219
隐瞒了意图╮
隐瞒了意图╮ 2021-01-20 02:18

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 po

相关标签:
1条回答
  • 2021-01-20 02:33

    Yes, there is a way to compare two images/textures using UIImage.

    - (BOOL)image:(UIImage *)image1 isEqualTo:(UIImage *)image2
    {
        NSData *data1 = UIImagePNGRepresentation(image1);
        NSData *data2 = UIImagePNGRepresentation(image2);
    
        return [data1 isEqual:data2];
    }
    
    0 讨论(0)
提交回复
热议问题