多线程异步加载图片的问题

求教大神们,在LOADing界面中通过异步加载图片到缓存中后,该用什么方法创建sprite,才是正确的?、才不会重新加载而是自动读取缓存中的纹理呢?

auto a =Sprite::createWithFrameName?
还是auto a =Sprite:: createWithTextureCache?、
还是auto a =Sprite::create(“xx.png”);

为什么我看了下源码关于 TextureCache的部分,他用的是 auto s5 = Sprite::create(“Images/grossini_dance_04.png”);,这样的话之前异步加载不是没意义了么

Sprite:create后会调用 initWithFile

这个方法里,纹理是通过 Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); 这个接口获取的
而 addImage()方法会先从缓存获取的

auto it = _textures.find(fullpath);
if( it != _textures.end() )
texture = it->second;

所以,只要在异步加载中已经添加的纹理,用
auto a =Sprite::createWithFrameName?
还是auto a =Sprite:: createWithTextureCache?、
还是auto a =Sprite::create(“xx.png”);

都是优先在缓存中寻找是否有纹理存在是吗

是啊
也就是TextureCache和SpriteFrameCache都有缓存就是有缓存了