如何为 SpriteKit 创建图集 [英] How to create atlas for SpriteKit
本文介绍了如何为 SpriteKit 创建图集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何为 SpriteKit 创建图集?我试图将我所有的图像转移到某个文件夹并给它扩展名.结果文件夹将称为somefolder.atlas".使用方法对吗?
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 ?
推荐答案
听起来不错.确保您还在 Xcode 设置中启用了图集生成(查看 官方文档关于这一点,并附有分步图片).
Sounds correct. Make sure you also enable atlas generation in Xcode settings (check out the official documentation about this, with step-by-step pictures).
然后,假设您的 atlas 文件夹命名为somefolder.atlas"并且它包含一个文件1.png",您将执行以下操作:
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];
这篇关于如何为 SpriteKit 创建图集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文