diff --git a/cocos2d/core/load-pipeline/downloader.js b/cocos2d/core/load-pipeline/downloader.js index 9173b9909a..229bdb6f5f 100644 --- a/cocos2d/core/load-pipeline/downloader.js +++ b/cocos2d/core/load-pipeline/downloader.js @@ -42,7 +42,7 @@ else { function downloadScript (item, callback, isAsync) { var url = item.url, - d = document, + d = document, s = document.createElement('script'); s.async = isAsync; s.src = urlAppendTimestamp(url); @@ -129,8 +129,8 @@ var FONT_TYPE = { '.svg' : 'svg' }; function _loadFont (name, srcs, type){ - var doc = document, - path = cc.path, + var doc = document, + path = cc.path, fontStyle = document.createElement('style'); fontStyle.type = 'text/css'; doc.body.appendChild(fontStyle); @@ -167,8 +167,8 @@ function _loadFont (name, srcs, type){ } function downloadFont (item, callback) { var url = item.url, - type = item.type, - name = item.name, + type = item.type, + name = item.name, srcs = item.srcs; if (name && srcs) { if (srcs.indexOf(url) === -1) { @@ -194,7 +194,7 @@ function downloadFont (item, callback) { var reusedArray = []; function downloadUuid (item, callback) { - var uuid = item.id; + var uuid = item.uuid; var self = this; cc.AssetLibrary.queryAssetInfo(uuid, function (error, url, isRawAsset) { if (error) { @@ -308,7 +308,7 @@ var ID = 'Downloader'; * // This will match all url with `.scene` extension or all url with `scene` type * 'scene' : function (url, callback) {} * }); - * + * * @method Downloader * @param {Object} extMap Custom supported types with corresponded handler */ diff --git a/cocos2d/core/load-pipeline/loading-items.js b/cocos2d/core/load-pipeline/loading-items.js index 266cc323a3..7c89f27317 100644 --- a/cocos2d/core/load-pipeline/loading-items.js +++ b/cocos2d/core/load-pipeline/loading-items.js @@ -52,7 +52,7 @@ function createItem (id, queueId) { } result = { queueId: queueId, - url: id.url || id.id, + url: id.url, error: null, content: null, complete: false, diff --git a/cocos2d/core/load-pipeline/pipeline.js b/cocos2d/core/load-pipeline/pipeline.js index 3dfe9c29b0..c33738456d 100644 --- a/cocos2d/core/load-pipeline/pipeline.js +++ b/cocos2d/core/load-pipeline/pipeline.js @@ -72,7 +72,7 @@ function syncFlow (item) { var pipeId = this.id; var itemState = item.states[pipeId]; var next = this.next; - + if (item.error || itemState === ItemState.WORKING || itemState === ItemState.ERROR) { return; } @@ -252,6 +252,10 @@ JS.mixin(Pipeline.prototype, { if (pipe) { for (i = 0; i < items.length; i++) { item = items[i]; + var url = cc.AssetLibrary._getAssetUrl(item.uuid); + if (url && !item.url) { + item.id = item.url = url; + } this._cache[item.id] = item; pipe.flowIn(item); } @@ -364,6 +368,7 @@ JS.mixin(Pipeline.prototype, { if (!item) return item; + // downloader.js downloadUuid if (item.alias) item = this._cache[item.alias]; @@ -409,4 +414,4 @@ JS.mixin(Pipeline.prototype, { } }); -cc.Pipeline = module.exports = Pipeline; \ No newline at end of file +cc.Pipeline = module.exports = Pipeline; diff --git a/cocos2d/core/platform/CCAssetLibrary.js b/cocos2d/core/platform/CCAssetLibrary.js index f5c99a50ed..36a65aea51 100644 --- a/cocos2d/core/platform/CCAssetLibrary.js +++ b/cocos2d/core/platform/CCAssetLibrary.js @@ -73,6 +73,7 @@ var AssetLibrary = { // var writeMainCache = typeof (options && options.writeMainCache) !== 'undefined' ? writeMainCache : true; var item = { id: uuid, + uuid: uuid, type: 'uuid' }; if (options && options.existingAsset) { @@ -143,6 +144,14 @@ var AssetLibrary = { } }, + _getAssetUrl: function (uuid) { + var info = _uuidToRawAsset[uuid]; + if (info) { + return _rawAssetsBase + info.url; + } + return null; + }, + /** * @method queryAssetInfo * @param {String} uuid