我得到下面的代碼中的錯誤:無法將類型的價值「的NSMutableArray」預期參數類型「[SKTexture]」
func prepareAnimationForDictionary(settings: NSDictionary,repeated: Bool) -> SKAction {
let atlas: SKTextureAtlas =
SKTextureAtlas(named: settings["AtlasFileName"] as! String)
let textureNames:NSArray = settings["Frames"] as! NSArray
let texturePack: NSMutableArray = []
for texPath in textureNames {
texturePack.addObject(atlas.textureNamed(texPath as! String))
}
let timePerFrame: NSTimeInterval = Double(1.0/(settings["FPS"]
as! Float))
let anim:SKAction = SKAction.animateWithTextures(texturePack,
timePerFrame: timePerFrame) // the error I get is here
if repeated {
return SKAction.repeatActionForever(anim)
}else{
return anim
}
檢查此答案http://stackoverflow.com/questions/25837539/how-can-i-cast-an-nsmutablearray-to-a-swift-array-of-a-specific-type#25837720 –