简体   繁体   中英

How to create atlas for SpriteKit

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 ?

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM