2

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.

ARR
  • 2,074
  • 1
  • 19
  • 28
  • This has happened to me a few times, and it's always been a problem with one of my png files. I'm not sure what exactly. Once I determine which file it is, I can generate a new png, and that fixes the problem. – SlimeBaron Nov 05 '20 at 16:32

0 Answers0