我在从 SKSpriteNode 的 .xcassets 图像集中加载图像时遇到问题。
虽然它在 iOS 8.x 上运行良好[SKSpriteNode spriteNodeWithImageNamde:图像名称]它不适用于某些运行 iOS 9 的设备。例如,它适用于 iPhone 6/6 Plus 和 iPad Air,但不适用于 iPod Touch 5G。
适用于运行 iOS 8.x 的所有设备,但不适用于运行 iOS 9.x 的所有设备(例如 iPod Touch 5g)(Xcode 7、Xcode 7.1 Beta 3):
SKSpriteNode *background = [SKSpriteNode spriteNodeWithImageNamed:@"MenuBackgroundImage"];
background.anchorPoint = CGPointMake(0, 0);
background.zPosition = 100;
[self addChild:background];
有趣的是,如果我像这样加载图像,它可以在 iOS 9 上运行:
SKTexture *imageTexture = [SKTexture textureWithImage:[UIImage imageNamed:@"MenuBackgroundImage"]];
SKSpriteNode* background = [SKSpriteNode spriteNodeWithTexture:imageTexture];
问题是,如果我使用 UIImage 加载图像,内部缓存将无法工作。有谁知道如何在 iOS 9 中正确从 .xcassets 加载 ImageSet 以便它在所有设备上运行?
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)