iOS 9 / Xcode 7: SKSpriteNode spriteNodeWithImageNamed not working on some devices

戏子无情 提交于 2019-12-10 15:38:50

问题


I am having problems to load a image from a .xcassets imageset for a SKSpriteNode.

While it worked fine on iOS 8.x with [SKSpriteNode spriteNodeWithImageNamde:imageName] it doesn't work on some devices on iOS 9. For example it works on iPhone 6/6 Plus and iPad Air but not on the iPod Touch 5G.

Works on all devices with iOS 8.x but not on all devices (for example iPod Touch 5g) on iOS 9.x (Xcode 7, Xcode 7.1 Beta 3):

SKSpriteNode *background = [SKSpriteNode spriteNodeWithImageNamed:@"MenuBackgroundImage"];
background.anchorPoint = CGPointMake(0, 0);
background.zPosition = 100;
[self addChild:background];

The interesting thing is that it works on iOS 9 if I load the image like this:

SKTexture *imageTexture = [SKTexture textureWithImage:[UIImage imageNamed:@"MenuBackgroundImage"]];
SKSpriteNode* background = [SKSpriteNode spriteNodeWithTexture:imageTexture];

The problem is that if I load the image with UIImage that the internal caching won't work. Does anybody know how to load a ImageSet from a .xcassets in iOS 9 correctly so that it works on ALL devices?

来源:https://stackoverflow.com/questions/32987329/ios-9-xcode-7-skspritenode-spritenodewithimagenamed-not-working-on-some-devic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!