我按照官方贴,增加热更新的代码后,打包才android包,安装后不能运行起来,附上截图:
js的文件包含都是放在jsList.js文件中的 ,project.json里面没有包含任何js。
即使不走更新代码,直接走加载,也不行;
不知道各位大神是怎么做的啊
我按照官方贴,增加热更新的代码后,打包才android包,安装后不能运行起来,附上截图:
js的文件包含都是放在jsList.js文件中的 ,project.json里面没有包含任何js。
即使不走更新代码,直接走加载,也不行;
不知道各位大神是怎么做的啊
你点击一下那个play试试!
点play就进去了。。。好坑啊
我把热更新的代码加上,就又不行了
我把代码贴出来:
=============================project.json==============================
{
“project_type”: “javascript”,
"debugMode" : 1,
"showFPS" : true,
"frameRate" : 60,
"id" : "gameCanvas",
"renderMode" : 0,
"engineDir":"frameworks/cocos2d-html5",
"modules" : "cocos2d", "extensions"],
"jsList" :
]
}
===========================main.js==========================
cc.game.onStart = function(){
cc.view.setDesignResolutionSize(800, 450, cc.ResolutionPolicy.SHOW_ALL);
cc.view.resizeWithBrowserSize(true);
var failCount = 0;
var maxFailCount = 1; //最大错误重试次数
/**
* 自动更新js和资源
*/
var AssetsManagerLoaderScene = cc.Scene.extend({
_am:null,
_progress:null,
_percent:0,
run:function(){
if (!cc.sys.isNative) {
this.loadGame();
return;
}
var layer = new cc.Layer();
this.addChild(layer);
this._progress = new cc.LabelTTF.create("update 0%", "Arial", 12);
this._progress.x = cc.winSize.width / 2;
this._progress.y = cc.winSize.height / 2 + 50;
layer.addChild(this._progress);
var storagePath = (jsb.fileUtils ? jsb.fileUtils.getWritablePath() : "./");
this._am = new jsb.AssetsManager("res/project.manifest", storagePath);
this._am.retain();
if (!this._am.getLocalManifest().isLoaded())
{
cc.log("Fail to update assets, step skipped.");
this.loadGame();
}
else
{
var that = this;
var listener = new cc.EventListenerAssetsManager(this._am, function(event) {
switch (event.getEventCode()){
case cc.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST:
cc.log("No local manifest file found, skip assets update.");
that.loadGame();
break;
case cc.EventAssetsManager.UPDATE_PROGRESSION:
that._percent = event.getPercent();
cc.log(that._percent + "%");
var msg = event.getMessage();
if (msg) {
cc.log(msg);
}
break;
case cc.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
case cc.EventAssetsManager.ERROR_PARSE_MANIFEST:
cc.log("Fail to download manifest file, update skipped.");
that.loadGame();
break;
case cc.EventAssetsManager.ALREADY_UP_TO_DATE:
cc.log("ALREADY_UP_TO_DATE.");
that.loadGame();
break;
case cc.EventAssetsManager.UPDATE_FINISHED:
cc.log("Update finished.");
that.loadGame();
break;
case cc.EventAssetsManager.UPDATE_FAILED:
cc.log("Update failed. " + event.getMessage());
failCount++;
if (failCount < maxFailCount)
{
that._am.downloadFailedAssets();
}
else
{
cc.log("Reach maximum fail count, exit update process");
failCount = 0;
that.loadGame();
}
break;
case cc.EventAssetsManager.ERROR_UPDATING:
cc.log("Asset update error: " + event.getAssetId() + ", " + event.getMessage());
that.loadGame();
break;
case cc.EventAssetsManager.ERROR_DECOMPRESS:
cc.log(event.getMessage());
that.loadGame();
break;
default:
break;
}
});
cc.eventManager.addListener(listener, 1);
this._am.update();
cc.director.runScene(this);
}
this.schedule(this.updateProgress, 0.5);
},
loadGame:function(){
//jsList是jsList.js的变量,记录全部js。
cc.loader.loadJs("src/jsList.js"], function(){
cc.loader.loadJs(jsList, function(){
cc.director.runScene(new HelloWorldScene());
});
});
},
updateProgress:function(dt){
this._progress.string = "update" + this._percent + "%";
},
onExit:function(){
cc.log("AssetsManager::onExit");
this._am.release();
this._super();
}
});
var scene = new AssetsManagerLoaderScene();
scene.run();
};
cc.game.run();
============================jsList.js==============================
var jsList =
"src/resource.js",
"src/app.js"
]
==============================project.manifest==================================
{
“packageUrl” : “http://203.195.235.189:8080/res”,
“remoteManifestUrl” : “http://203.195.235.189:8080/res/project.manifest”,
“remoteVersionUrl” : “http://203.195.235.189:8080/res/version.manifest”,
“version” : “1.0.0”,
“groupVersions” : {
“1” : “1.0.1”
},
“engineVersion” : “3.0 rc0”,
“assets” : {
},
"searchPaths" :
]
}
=========================version.manifest=============================
{
“packageUrl” : “http://203.195.235.189:8080/res”,
“remoteManifestUrl” : “http://203.195.235.189:8080/res/project.manifest”,
“remoteVersionUrl” : “http://203.195.235.189:8080/res/version.manifest”,
“version” : “1.0.0”,
“groupVersions” : {
“1” : “1.0.1”
},
“engineVersion” : “3.0 rc0”
}