微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决在 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 举报,一经查实,本站将立刻删除。