栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

SKTextureAtlas不再在iOS 10中共享纹理

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SKTextureAtlas不再在iOS 10中共享纹理

为了解决这个问题,我不得不想出一种方法来缓存纹理,以使其不会重复:

private var textureCache = [String: SKTexture]()extension SKTextureAtlas{    func texturesWithNames(_ names:[String]) -> [SKTexture]    {        var textures = [SKTexture]()        names.forEach({textures.append(textureNamed($0))})        return textures    }    func cachedTextureWithName(_ name:String) -> SKTexture    {        if  textureCache[name] == nil        { textureCache[name] = textureNamed(name)        }        return textureCache[name]!    }    func cachedTexturesWithNames(_ names:[String]) -> [SKTexture]    {        var textures = [SKTexture]()        names.forEach({textures.append(cachedTextureWithName($0))})        return textures    }    func clearCache()    {        textureCache = [String: SKTexture]()    }}extension SKTexture{    var name : String    {        return self.description.slice(start: "'",to: "'")!    }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/426994.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号