- Creator 版本号:1.4.0
因为要检测子游戏的更新,所以本地子游戏的manifest文件肯定要按文件夹放置,虽然不大,但是如果子游戏多了,那不是要很多个文件夹。 所以想通过代码生成本地默认的manifest文件。代码如下:
this._storagePath = ((jsb.fileUtils ? jsb.fileUtils.getWritablePath() : '/')+"asset/"+wKindID);
var UIRLFILE = s_Path_Url+wKindID;
var filees = this._storagePath+"/project.manifest";
this.manifestUrl = filees;
var customManifestStr = JSON.stringify(
{
"packageUrl": UIRLFILE,
"remoteManifestUrl": UIRLFILE+"/project.manifest",
"remoteVersionUrl" : UIRLFILE+"/version.manifest",
"version": szFirstVersion,
"assets": {},
"searchPaths": []
});
var versionCompareHandle = function (versionA, versionB)
{
var vA = versionA.split('.');
var vB = versionB.split('.');
for (var i = 0; i < vA.length; ++i)
{
var a = parseInt(vA[i]);
var b = parseInt(vB[i] || 0);
if (a === b)
{
continue;
}
else
{
return a - b;
}
}
if (vB.length > vA.length)
{
return -1;
}
else
{
return 0;
}
};
this._am = new jsb.AssetsManager('', this._storagePath, versionCompareHandle);
if (!cc.sys.ENABLE_GC_FOR_NATIVE_OBJECTS)
{
this._am.retain();
}
if (cc.sys.os === cc.sys.OS_ANDROID)
{
this._am.setMaxConcurrentTask(2);
}
if (this._am.getState() === jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST)
{
var bExist = jsb.fileUtils.isFileExist(filees);
if( bExist )
{
this._am.loadLocalManifest(this.manifestUrl);
}
else
{
var manifest = new jsb.Manifest(customManifestStr); //这里开始出错了 new失败了。
this._am.loadLocalManifest( manifest );
}
}
大周末的 有大佬逛论坛没 求助啊!