How to check whether the sprite sheet is already loaded?

How to check whether the sprite sheet is already loaded?
0.0 0

#1

When the user visit a scene for the first time, the sprite sheet will be loaded. Later on the game if visits again, why should i load the sprite sheet again?

Is there a way to check if the sprite sheet is already loaded?


#2

If sprite sheet loaded first time then it will be remain in memory, so don’t worry about that.
If you need manually preload and unload your sprite sheet you can write this:

auto cache = SpriteFrameCache::getInstance();
// for preload 
cache->addSpriteFramesWithFile("mysheet.plist");
// for unload
cache->removeSpriteFramesFromFile("mysheet.plist");

#3

What will happen if i load the same sprite sheet?
For example, in my menu scene, i have loaded a sprite sheet.
Now after completing the game, if the user return to the menu scene, it will again load the spritesheet.

So, i want to check whether the sprite sheet was already loaded in the memory.
How can i do that?


#4

Nothing happen. it’s not loaded again.