How to create an atlas for SpriteKit

How to create an atlas for SpriteKit? I tried to transfer all my images to some folder and give it an extension. The folder with the result will be called "somefolder.atlas". Is it right to use?

+3
source share
1 answer

Sounds right. Make sure that you also activate the creation of the atlas in the Xcode settings (see the official documentation about this, with step-by-step images).

Then, assuming your atlas folder is called "somefolder.atlas" and it contains the file "1.png", you would do something like this:

SKTextureAtlas *atlas = [SKTextureAtlas atlasNamed:@"somefolder"];
SKTexture *texture = [atlas textureNamed:@"1"];
SKSpriteNode *sprite = [SKSpriteNode spriteWithTexture:texture];
+6
source

All Articles