I initialise about 30 animated textures in my view controller on game load like this:
for i=0; i<atlasName.count; i++ {
frameNumber = animationTextures.animationTextureAtlas[i].textureNames.count
firstFrameName = "\(atlasName[i])1"
animationTextures.animationFrames.append([animationTextures.animationTextureAtlas[i].textureNamed(firstFrameName)])
for j=2; j<=frameNumber; j++ {
var frameName = "\(atlasName[i])\(j)"
animationTextures.animationFrames[i].append(animationTextures.animationTextureAtlas[i].textureNamed(frameName))
}
animationTextures.firstFrame.append(animationTextures.animationFrames[i][0])
}
Basically I put all of the animations into an array so I can access them easily.
During the game each of these animations appear for a short amount of time and when I don't need them I use the .removeFromParent() to delete it, but the problem is that it still stays in the memory of the device and therefor once about 15-20 animations appear in the game and go into the memory it gets to about 450-500MB and crashes the game on iPhone 4 and 4s.
Does anyone know how I can really remove that animation from memory so that it doesn't take up space once it's not needed anymore?