I'm trying to create a "Loading Screen" to preload all the textures.
I have the following in GameViewController.swift :
class GameViewController: UIViewController {
var catAtlas = SKTextureAtlas(named:"cat@2x")
//And many more atlas
override func viewDidLoad() {
super.viewDidLoad()
var textureAtlas = NSMutableArray()
textureAtlas.addObject(catAtlas)
SKTextureAtlas.preloadTextureAtlases(textureAtlas, withCompletionHandler: {
//Present Scene
}
})
}
And in a class called Obstacles.swift which is implemented in GameScene.swift:
class Obstacles {
init() { }
var catAtlas = SKTextureAtlas(named:"cat@2x")
func catAnimation(){
//Where catAtlas is used
}
}
This way the textures are stored in RAM, but the frame rate does not change (It`s the same without preload). And if I do the following the frame rate worsens:
var pinataTextAtlas = GameViewController().catAtlas
What am I doing wrong or how I can fix this?
Thank You! (Sorry for my english)
Preloading will only improve the frame rate if you see frame rate drops due to loading textures at runtime. Clearly this isn't the case for you.
Here's some possible things you can do to narrow it down:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.