I am new to the forum but have been using cocos2dx for a while now. Recently I tried using CCTextureCache::addImageAsync but found two oddities that were unexpected:
- If you have multiple requestors for the same file before it’s in the cache, then we hit the disk multiple times and load the file multiple times.
- Only one callback seems to run each frame so if you queue 500 images to load asynchronously, even if all the images have loaded in one frame, it will take 500 frames before all callbacks are run.
On my local branch of cocos, I have solved 1) by maintaining a vector of callbacks in AsyncStruct and then adding callbacks to that vector when the file that AsyncStruct is associated with is requested again.
For 2) I just added a while loop that runs over all loaded images and runs the callbacks for them. If there is a lot of time spent in each of these callbacks I can see how you might want to divide the list of callbacks over multiple frames but in the simple case of doing a setImage on CCSprite with the loaded texture I have not run into that problem.
If 1) and 2) were purposefully designed in for other reasons please let me know! Also I would be happy to contribute these changes to the main cocos2dx repo but I am not sure what the process is.