如果iOS项目有UIImages字典,如何在运行时从字典图像中正确创建SKTextureAtlas?我无法实现这个目标,虽然Apple的SKTextureAtlas类引用在声明图集时提示如下:convenience init!(字典属性:[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 = ???
答案 0 :(得分:1)
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)