diff --git a/src/pixi/loaders/JsonLoader.js b/src/pixi/loaders/JsonLoader.js index 17a2a95..1366b7e 100644 --- a/src/pixi/loaders/JsonLoader.js +++ b/src/pixi/loaders/JsonLoader.js @@ -127,22 +127,18 @@ if (rect) { - PIXI.TextureCache[i] = new PIXI.Texture(this.texture, { - x: rect.x, - y: rect.y, - width: rect.w, - height: rect.h - }); - - PIXI.TextureCache[i].crop = new PIXI.Rectangle(rect.x, rect.y, rect.w, rect.h); - + var textureSize = new PIXI.Rectangle(rect.x, rect.y, rect.w, rect.h); + var crop = textureSize.clone(); + var trim = null; + // Check to see if the sprite is trimmed if (frameData[i].trimmed) { var actualSize = frameData[i].sourceSize; var realSize = frameData[i].spriteSourceSize; - PIXI.TextureCache[i].trim = new PIXI.Rectangle(realSize.x, realSize.y, actualSize.w, actualSize.h); + trim = new PIXI.Rectangle(realSize.x, realSize.y, actualSize.w, actualSize.h); } + PIXI.TextureCache[i] = new PIXI.Texture(this.texture, textureSize, crop, trim); } } diff --git a/src/pixi/loaders/JsonLoader.js b/src/pixi/loaders/JsonLoader.js index 17a2a95..1366b7e 100644 --- a/src/pixi/loaders/JsonLoader.js +++ b/src/pixi/loaders/JsonLoader.js @@ -127,22 +127,18 @@ if (rect) { - PIXI.TextureCache[i] = new PIXI.Texture(this.texture, { - x: rect.x, - y: rect.y, - width: rect.w, - height: rect.h - }); - - PIXI.TextureCache[i].crop = new PIXI.Rectangle(rect.x, rect.y, rect.w, rect.h); - + var textureSize = new PIXI.Rectangle(rect.x, rect.y, rect.w, rect.h); + var crop = textureSize.clone(); + var trim = null; + // Check to see if the sprite is trimmed if (frameData[i].trimmed) { var actualSize = frameData[i].sourceSize; var realSize = frameData[i].spriteSourceSize; - PIXI.TextureCache[i].trim = new PIXI.Rectangle(realSize.x, realSize.y, actualSize.w, actualSize.h); + trim = new PIXI.Rectangle(realSize.x, realSize.y, actualSize.w, actualSize.h); } + PIXI.TextureCache[i] = new PIXI.Texture(this.texture, textureSize, crop, trim); } } diff --git a/src/pixi/textures/Texture.js b/src/pixi/textures/Texture.js index 112875b..7b0124e 100644 --- a/src/pixi/textures/Texture.js +++ b/src/pixi/textures/Texture.js @@ -16,8 +16,10 @@ * @constructor * @param baseTexture {BaseTexture} The base texture source to create the texture from * @param frame {Rectangle} The rectangle frame of the texture to show + * @param [crop] {Rectangle} The area of original texture + * @param [trim] {Rectangle} Trimmed texture rectangle */ -PIXI.Texture = function(baseTexture, frame) +PIXI.Texture = function(baseTexture, frame, crop, trim) { /** * Does this Texture have any frame data assigned to it? @@ -60,7 +62,7 @@ * @property trim * @type Rectangle */ - this.trim = null; + this.trim = trim; /** * This will let the renderer know if the texture is valid. If its not then it cannot be rendered. @@ -102,7 +104,7 @@ * @property crop * @type Rectangle */ - this.crop = new PIXI.Rectangle(0, 0, 1, 1); + this.crop = crop || new PIXI.Rectangle(0, 0, 1, 1); if (baseTexture.hasLoaded) {