how to check if all background texture loads finished?

how to check if all background texture loads finished?
0.0 0



I’m preloading the backgrounds for a scrolling level using:


If the callback object disappears before the texture loading finishes in the background (for example exit game level to menu), the game obviously crashes.

What is the proper way to check if all background image loads are finished? Is there any mechanism for this in cocos2dx, or is this the game’s responsibility?



I’d consider creating some kind of GameSpriteManager singleton, which would be the callback object for this. Then you can also in a simple way check with it everytime you need some sprites if they are there.
It also delegates your sprite loading outside of your game logic.


Thanks for the suggestion. I already had the texture loading outside of game logic, so I was just looking for a simple way of checking if there are active async image loads.

So I added a method to the CCCextureCache:

bool CCTextureCache::isAsyncLoading()
    return s_nAsyncRefCount != 0;

(Submitted as pull request 4317 on github: