I am trying to create an animation with the use of SKTextureAtlas. However I get an EXC_BAD_ACCESS error when I try to construct the SKTextureAtlas, with a dictionary of [String: NSString]. My code looks as following:
func generateAtlasForPart(maxFrames: Int) -> SKTextureAtlas {
var atlasDict: [String: NSString] = [:]
for frameNumber in 0...maxFrames {
let framePath = "\(String(format: "%03d", frameNumber)).png"
atlasDict["\(frameNumber)"] = framePath as NSString
}
let atlas = SKTextureAtlas(dictionary: atlasDict)
return atlas
}
When I put a breakpoint after the first iteration of the loop, it will (sometimes) work. I initiate the process from didMove function of the scene. The images do exists, I've loaded them one by one with SKTexture and it was working.
I've tried to construct the SKTextureAtlas with [NSString: UIImage], but that did not help either.
I think I am doing something wrong but I really can't find out what.