Reputation: 161
I am having a really weird problem with my SpriteKit Game. It works perfectly fine on my iPad and on the iOS simulators, but when I run it on my iPod Touch, there is an error. I located where the error was coming from, and it is here, where I try to access one of the items in an array of textures:
let firstFrame = Frames[0]
The error is basically saying that Frames[0] doesn't exist, and indeed, on iPod Touch, when I print the number of items in the array, there is nothing. On the other devices, the array has all the textures it should have.
Here is where and how I am loading some textures from a texture atlas into the array for an animation:
let birdAtlas = SKTextureAtlas(named: "bird")
var Frames = [SKTexture]() ////Here is the array into which I am loading textures
let numImages = birdAtlas.textureNames.count ////Should be 12, as is on devices other than iPod
print(numImages) ////On iPod Touch, numImages = 0
for var i=1; i<=numImages/3; i++ {
let birdTextureName = "\(currentBird)\(i)"
print(birdTextureName)
Frames.append(birdAtlas.textureNamed(birdTextureName))
} //^^This loop adds the textures 1 - 4 to the array
for var i=numImages/3; i>=1; i-- {
let birdTextureName = "\(currentBird)\(i)"
print(birdTextureName)
Frames.append(birdAtlas.textureNamed(birdTextureName))
} //^^This loop adds the textures 3 - 1 to the array
When this is run on any other device than the iPod Touch, the textures in my atlas load into the array Frames. However, on the iPod Touch, no textures are loaded into the array. Here is an image of the texture atlas: link to image of texture array
Again, the textures load into the array perfectly and animates perfectly on iPad and iPhone simulators, as well as a real iPad device. It just doesn't work on iPod Touch, and the error is causing the app not to be able to load. The iPod touch is running iOS 9, just like the other devices.
Any help is appreciated! Thanks!
Upvotes: 1
Views: 72
Reputation: 59536
Since my previous comment does fix the problem I'm posting it as an answer along with a more detailed explanation.
Project Navigator
pressing cmd + 1Assets.xcassets
New Sprite Atlas
Sprites
folder has appeared, just drag images from the Finder to this folder to populate your Sprite Atlas.Upvotes: 1