如何为SpriteKit创建地图集(How to create atlas for SpriteKit)

编程入门 行业动态 更新时间:2024-10-08 22:46:32
如何为SpriteKit创建地图集(How to create atlas for 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设置中启用了图集生成(查看有关此内容的官方文档 ,并逐步显示图片)。

然后,假设你的atlas文件夹名为“somefolder.atlas”并且它包含一个文件“1.p​​ng”,你可以这样做:

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

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

更多推荐

本文发布于:2023-08-06 12:28:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1449360.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:地图集   何为   atlas   SpriteKit   create

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!