为什么我要做这些选项中的一个而不是另一个...我想,除了我必须编写的代码之外,我不明白它们有什么不同
在Xcode中-make一个名为"HeroSprites.atlas“的纹理地图集,带有图像"Hero.png”和可能的其他变体。
示例1:
SKSpriteNode* heroSprite = [SKSpriteNode spriteNodeWithImageNamed:@"Hero"];
//pulls in image from the atlas without having created an atlas object first
[self addChild: heroSprite];示例2:
SKTextureAtlas* heroAtlas = [SKTextureAtlas atlasNamed:@"HeroAtlas"];
SKSpriteNode* heroSprite = [SKSpriteNode spriteNodeWithTexture:[heroAtlas textureNamed:@"Hero"]];
//pulls in image from the atlas after having created an atlas object first
[self addChild:heroSprite];据我所知,两者似乎都将地图集加载到内存中,以便我可以调用其中的所有图像。我能想到的唯一原因是,如果在不同的地图集中有相同的图像名称,但避免这种情况是很容易的。
发布于 2014-02-26 21:17:28
以下是您应该了解的关于SKTextureAtlas的信息:
directory.
发布于 2014-05-29 22:30:36
SKTextureAtlas可以提高内存使用率和渲染性能。例如,如果具有使用不同纹理绘制的精灵的场景,精灵工具包将为每个纹理执行一个绘制过程。但是,如果所有纹理都是从相同的纹理贴图集加载的,那么Sprite Kit可以在单个绘制过程中渲染精灵-并且使用较少的内存来执行此操作。无论何时,只要有总是一起使用的纹理,就应该将它们存储在atlas中。
https://stackoverflow.com/questions/21362043
复制相似问题