优化热更新代码

This commit is contained in:
leo
2019-03-23 00:57:16 +08:00
parent b9fc4f0f13
commit 059d874600

View File

@@ -256,6 +256,8 @@ cc.Class({
updateCb: function (event) {
var needRestart = false;
var failed = false;
var aleardyUpdate = false;
switch (event.getEventCode()) {
case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST:
// this.panel.info.string = 'No local manifest file found, hot update skipped.';
@@ -273,6 +275,7 @@ cc.Class({
case jsb.EventAssetsManager.ALREADY_UP_TO_DATE:
// this.panel.info.string = 'Already up to date with the latest remote version.';
failed = true;
aleardyUpdate = true;
break;
case jsb.EventAssetsManager.UPDATE_FINISHED:
// console.log('UPDATE_FINISHED');
@@ -294,16 +297,14 @@ cc.Class({
break;
}
//下载失败
//下载失败
if (failed) {
// console.log('Hotupdate failure');
this.onFailure(ErrCode.updateFailed);
cc.eventManager.removeListener(this._updateListener);
this._updateListener = null;
this._updating = false;
}
if (needRestart) {
} else if (needRestart) {
// console.log('Hotupdate success');
cc.eventManager.removeListener(this._updateListener);
this._updateListener = null;
@@ -314,6 +315,9 @@ cc.Class({
jsb.fileUtils.setSearchPaths(searchPaths);
cc.audioEngine.stopAll();
cc.game.restart();
} else if (aleardyUpdate) {
//进入游戏
this.onEnterGame();
}
},