gpt4 book ai didi

ios - 从字典创建 SKTextureAtlas

转载 作者:行者123 更新时间:2023-11-28 07:07:04 24 4
gpt4 key购买 nike

如果一个 iOS 项目有一个 UIImages 字典,如何在运行时从字典图像正确创建 SKTextureAtlas?我无法实现这个目标,尽管 Apple 的 SKTextureAtlas 类引用在声明图集时建议如下:convenience init!(dictionary properties: [NSObject : AnyObject])。

例如,如何完成或修改以下代码以从 tempDictionary 中的 UIImages 创建 SKTextureAtlas?

var strawberryDrawing:UIImage = UIImage(named: "strawberry")!
var bananaDrawing:UIImage = UIImage(named: "banana")!

var tempDictionary:[String:UIImage] = ["First Fruit":strawberryDrawing, "Second Fruit":bananaDrawing]

var atlasOfFruitDrawings:SKTextureAtlas = ???

最佳答案

let strawberryDrawing = UIImage(named: "strawberry")!
let bananaDrawing = UIImage(named: "banana")!
let tempDictionary: [NSObject:AnyObject] = ["First Fruit":strawberryDrawing, "Second Fruit":bananaDrawing]
let atlasOfFruitDrawings = SKTextureAtlas(dictionary: tempDictionary)

关于ios - 从字典创建 SKTextureAtlas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30114304/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com