add progress param to the preloadScene (#2907)

This commit is contained in:
黄家辉
2018-06-27 09:52:17 +08:00
committed by pandamicro
parent 8ebb2bb9dd
commit 42fe5c3eac
2 changed files with 18 additions and 3 deletions
+17 -2
View File
@@ -582,14 +582,29 @@ cc.Director.prototype = {
*
* @method preloadScene
* @param {String} sceneName - The name of the scene to preload.
* @param {Function} [onProgress] - callback, will be called when the load progression change.
* @param {Number} onProgress.completedCount - The number of the items that are already completed
* @param {Number} onProgress.totalCount - The total number of the items
* @param {Object} onProgress.item - The latest item which flow out the pipeline
* @param {Function} [onLoaded] - callback, will be called after scene loaded.
* @param {Error} onLoaded.error - null or the error object.
*/
preloadScene: function (sceneName, onLoaded) {
preloadScene: function (sceneName, onProgress, onLoaded) {
if (onLoaded === undefined) {
onLoaded = onProgress;
onProgress = null;
}
var info = this._getSceneUuid(sceneName);
if (info) {
this.emit(cc.Director.EVENT_BEFORE_SCENE_LOADING, sceneName);
cc.loader.load({ uuid: info.uuid, type: 'uuid' }, function (error, asset) {
cc.loader.load({ uuid: info.uuid, type: 'uuid' },
function (completedCount, totalCount, item) {
if (onProgress) {
onProgress(completedCount, totalCount, item);
}
},
function (error, asset) {
if (error) {
cc.errorID(1210, sceneName, error.message);
}
+1 -1
View File
@@ -112,7 +112,7 @@ function CCLoader () {
this.downloader = downloader;
/**
* The downloader in cc.loader's pipeline, it's by default the third pipe.
* The loader in cc.loader's pipeline, it's by default the third pipe.
* It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid.
* You can add your own download function with addLoadHandlers
* @property loader