How to create atlas for SpriteKit

荒凉一梦 提交于 2019-12-01 05:49:50

问题


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 ?


回答1:


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


来源:https://stackoverflow.com/questions/21970781/how-to-create-atlas-for-spritekit

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