?html
1
2
|
Director::getInstance()->getTextureCache()->addImageAsync(reloadImages[curReloadImgNum],
CC_CALLBACK_1(LoadingScene::imageAsyncCallback,
this
));
|
廢話很少,直接上方法,沒有加載plist的api,咱們使用如1的方法加載png,而後在回調函數中加載plist。json
?api
1
2
|
Director::getInstance()->getTextureCache()->addImageAsync(reloadPlists[curReloadPlistNum]+
"png"
,
CC_CALLBACK_1(LoadingScene::plistImageAsyncCallback,
this
));
|
注意回調函數的參數,這是plist異步加載的關鍵,形參是png紋理。app
?異步
1
2
3
4
5
6
|
void
LoadingScene::plistImageAsyncCallback(cocos2d::Texture2D* texture)
{
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(reloadPlists[curReloadPlistNum].append(
"plist"
), texture);
curReloadPlistNum++;
loading =
true
;
}
|
相似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
;
}
|
?this
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
;
}
|