简体   繁体   English

如何为SpriteKit创建地图集

[英]How to create atlas for SpriteKit

How to create atlas for SpriteKit ? 如何为SpriteKit创建地图集? I tried to transfer all my images to some folder and give it extension. 我试图将我的所有图像传输到某个文件夹并给它扩展。 At result folder will called "somefolder.atlas" . 在结果文件夹中将调用“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). 确保您还在Xcode设置中启用了图集生成(查看有关此内容的官方文档 ,并逐步显示图片)。

Then, supposing your atlas folder is named "somefolder.atlas" and it contains a file "1.png", you would do something like this: 然后,假设你的atlas文件夹名为“somefolder.atlas”并且它包含一个文件“1.p​​ng”,你会这样做:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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