1

如果 iOS 项目有 UIImages 字典,如何在运行时从字典图像正确创建 SKTextureAtlas?我无法实现这个目标,尽管 Apple 的 SKTextureAtlas 类参考在声明图集时建议以下内容:方便初始化!(字典属性:[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 = ???
4

1 回答 1

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)
于 2015-05-08T01:29:16.437 回答