1.png的异步加载
1
2
|
Director::getInstance()->getTextureCache()->addImageAsync(reloadImages[curReloadImgNum],
CC_CALLBACK_1(LoadingScene::imageAsyncCallback,
this
));
|
2.plist和png一起的打包资源
废话不多,直接上方法,没有加载plist的api,我们使用如1的方法加载png,然后在回调函数中加载plist。
1
2
|
Director::getInstance()->getTextureCache()->addImageAsync(reloadPlists[curReloadPlistNum]+
"png"
,
CC_CALLBACK_1(LoadingScene::plistImageAsyncCallback,
this
));
|
注意回调函数的参数,这是plist异步加载的关键,形参是png纹理。
1
2
3
4
5
6
|
void
LoadingScene::plistImageAsyncCallback(cocos2d::Texture2D* texture)
{
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(reloadPlists[curReloadPlistNum].append(
"plist"
),texture);
curReloadPlistNum++;
loading =
true
;
}
|
3.plist和pvr.ccz一起的打包资源
类似2的方法。
1
2
3
4
5
6
7
8
|
Director::getInstance()->getTextureCache()->addImageAsync(reloadPvrPlists[curReloadPvrPlistNum] +
"pvr.ccz"
,
CC_CALLBACK_1(LoadingScene::pvrPlistImageAsyncCallback,
this
));
void
LoadingScene::pvrPlistImageAsyncCallback(cocos2d::Texture2D* texture)
{
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(reloadPvrPlists[curReloadPvrPlistNum].append(
"plist"
),texture);
curReloadPvrPlistNum++;
loading =
true
;
}
|
4.CocosStudio导出的.ExportJson后缀的动画文件
1
2
3
4
5
6
7
|
ArmatureDataManager::getInstance()->addArmatureFileInfoAsync(reloadExportJsons[curReloadExportJsonNum],
this
,schedule_selector(LoadingScene::jsonAsyncCallback));
void
LoadingScene::jsonAsyncCallback(
float
f)
{
curReloadExportJsonNum++;
loading =
true
;
}
|