在 SpriteKit 中使用不同的实例加载相同的纹理图集文件夹

问题描述

在 SpriteKit 中,系统是否足够智能,可以识别出如果我创建同一个图集文件夹的 2 个实例,它们是相同的图集,并且在并排使用它们时不会影响性能?如何在运行时验证这一点?或者,作为一名程序员,我是否必须明智地管理我创建的地图集以及我如何共享它们。

let atlas1 = SKTextureAtlas.init(named: "my-atlas-1.atlas")
let atlas2= SKTextureAtlas.init(named: "my-atlas-1.atlas") // Will SpriteKit reuse atlas1 here?
// create sprite node with image from atlas1
let node1 = SKSpriteNode.init(texture: atlas1.textureNamed("texture1.png"))
// create sprite node with image from atlas2
let node2 = SKSpriteNode.init(texture: atlas2.textureNamed("texture1.png"))
// Now during the rendering phase does the system realize that after rendering node1
//  node2 refers to a texture from the same texture atlas folder and does not need
//  to load atlas2 into the video memory area to render node2 ?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)