From 87900f331e863805e4232852017b48e9495335ea Mon Sep 17 00:00:00 2001 From: Nishigaki Nobuyuki Date: Fri, 20 Nov 2015 04:34:50 +0900 Subject: [PATCH] Added basePath support to SpriteSheetLoader --- src/preloadjs/LoadQueue.js | 2 +- src/preloadjs/loaders/SpriteSheetLoader.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/preloadjs/LoadQueue.js b/src/preloadjs/LoadQueue.js index 6e4e1e2..4f5c8cf 100644 --- a/src/preloadjs/LoadQueue.js +++ b/src/preloadjs/LoadQueue.js @@ -1475,7 +1475,7 @@ this.createjs = this.createjs || {}; for (var i = 0; i < this._availableLoaders.length; i++) { var loader = this._availableLoaders[i]; if (loader && loader.canLoadItem(item)) { - return new loader(item, preferXHR); + return new loader(item, preferXHR, this._basePath); } } diff --git a/src/preloadjs/loaders/SpriteSheetLoader.js b/src/preloadjs/loaders/SpriteSheetLoader.js index af8ee32..e4c457c 100644 --- a/src/preloadjs/loaders/SpriteSheetLoader.js +++ b/src/preloadjs/loaders/SpriteSheetLoader.js @@ -60,7 +60,7 @@ this.createjs = this.createjs || {}; * @extends AbstractLoader * @constructor */ - function SpriteSheetLoader(loadItem, preferXHR) { + function SpriteSheetLoader(loadItem, preferXHR, basePath) { this.AbstractLoader_constructor(loadItem, preferXHR, createjs.AbstractLoader.SPRITESHEET); // protected properties @@ -71,6 +71,7 @@ this.createjs = this.createjs || {}; * @private */ this._manifestQueue = null; + this._basePath = basePath; } var p = createjs.extend(SpriteSheetLoader, createjs.AbstractLoader); @@ -142,6 +143,9 @@ this.createjs = this.createjs || {}; */ p._loadManifest = function (json) { if (json && json.images) { + for(var i = json.images.length - 1; i >= 0; i--) { + json.images[i] = this._basePath + json.images[i]; + } var queue = this._manifestQueue = new createjs.LoadQueue(this._preferXHR, this._item.path, this._item.crossOrigin); queue.on("complete", this._handleManifestComplete, this, true); queue.on("fileload", this._handleManifestFileLoad, this);