So, I noticed this recommendation in one of the discussions here. It says that in order to release memory once you done with the textures, a possible solution will be the next:
- create UIImages with +imageWithContentsOfFile:
- create SKTextures from the resulting UIImage objects by calling SKTexture/+textureWithImage:(UIImage*).
I have memory issues that comes from the high res backgrounds and few embedded scroll views, so I tried the above implementation - and it works in terms of memory.
The problem is that it looks like when doing so, imageWithContentsOfFile: in retina devices, scales the @2x image by 2, so I need to explicit scale it again by 0.5.
How can I ensure the right scaling when calling this method?
Here is my code:
NSString *path = [[NSBundle mainBundle] pathForResource:@"sc_01_bg" ofType:@"png"];
UIImage *img = [UIImage imageWithContentsOfFile:path];
SKSpriteNode *backgroundSprite = [SKSpriteNode spriteNodeWithTexture:[SKTexture textureWithImage: img]];