How to create atlas for SpriteKit ? I tried to transfer all my images to some folder and give it extension. At result folder will called "somefolder.atlas" . Is it right way to use it ?
Asked
Active
Viewed 4,866 times
1 Answers
6
Sounds correct. Make sure you also enable atlas generation in Xcode settings (check out the official documentation about this, with step-by-step pictures).
Then, supposing your atlas folder is named "somefolder.atlas" and it contains a file "1.png", you would do something like this:
SKTextureAtlas *atlas = [SKTextureAtlas atlasNamed:@"somefolder"];
SKTexture *texture = [atlas textureNamed:@"1"];
SKSpriteNode *sprite = [SKSpriteNode spriteWithTexture:texture];

CodeSmile
- 64,284
- 20
- 132
- 217

Janis Kirsteins
- 2,128
- 16
- 17
-
1Thanks, it works :) Also I see that to enable texture atlas generation I need to have at least one .atlas in my project, otherwise this option is invisible – Igor Prusyazhnyuk Feb 23 '14 at 17:10