本文介绍了如何为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.p​​ng ,你会做这样的事情:

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创建地图集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-13 19:21