如何为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.png”,你可以这样做:
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];更多推荐
发布评论