diff --git a/src/pixi/loaders/JsonLoader.js b/src/pixi/loaders/JsonLoader.js index c50be0a..815e2d4 100644 --- a/src/pixi/loaders/JsonLoader.js +++ b/src/pixi/loaders/JsonLoader.js @@ -61,15 +61,40 @@ * @method load */ PIXI.JsonLoader.prototype.load = function () { - this.ajaxRequest = new PIXI.AjaxRequest(this.crossorigin); + + + if(window.XDomainRequest) + { + this.ajaxRequest = new window.XDomainRequest(); + } + else if (window.XMLHttpRequest) + { + this.ajaxRequest = new window.XMLHttpRequest(); + } + else + { + this.ajaxRequest = new window.ActiveXObject('Microsoft.XMLHTTP'); + } + + + + + // this.ajaxRequest = new PIXI.AjaxRequest(this.crossorigin); var scope = this; - this.ajaxRequest.onreadystatechange = function () { + + + + + this.ajaxRequest.onload = function () { scope.onJSONLoaded(); }; - this.ajaxRequest.open('GET', this.url, true); - if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType('application/json'); - this.ajaxRequest.send(null); + // this.ajaxRequest.open('GET', this.url, true); + // if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType('application/json'); + // this.ajaxRequest.send(null); + + this.ajaxRequest.open('GET',this.url,false); + this.ajaxRequest.send(); }; /** @@ -79,67 +104,67 @@ * @private */ PIXI.JsonLoader.prototype.onJSONLoaded = function () { - if (this.ajaxRequest.readyState === 4) { - if (this.ajaxRequest.status === 200 || window.location.protocol.indexOf('http') === -1) { - this.json = JSON.parse(this.ajaxRequest.responseText); + // if (this.ajaxRequest.readyState === 4) { + // if (this.ajaxRequest.status === 200 || window.location.protocol.indexOf('http') === -1) { + this.json = JSON.parse(this.ajaxRequest.responseText); - if(this.json.frames) - { - // sprite sheet - var scope = this; - var textureUrl = this.baseUrl + this.json.meta.image; - var image = new PIXI.ImageLoader(textureUrl, this.crossorigin); - var frameData = this.json.frames; + if(this.json.frames) + { + // sprite sheet + var scope = this; + var textureUrl = this.baseUrl + this.json.meta.image; + var image = new PIXI.ImageLoader(textureUrl, this.crossorigin); + var frameData = this.json.frames; - this.texture = image.texture.baseTexture; - image.addEventListener('loaded', function() { - scope.onLoaded(); + this.texture = image.texture.baseTexture; + image.addEventListener('loaded', function() { + scope.onLoaded(); + }); + + for (var i in frameData) { + var rect = frameData[i].frame; + if (rect) { + PIXI.TextureCache[i] = new PIXI.Texture(this.texture, { + x: rect.x, + y: rect.y, + width: rect.w, + height: rect.h }); - for (var i in frameData) { - var rect = frameData[i].frame; - if (rect) { - PIXI.TextureCache[i] = new PIXI.Texture(this.texture, { - x: rect.x, - y: rect.y, - width: rect.w, - height: rect.h - }); + // check to see ifthe sprite ha been trimmed.. + if (frameData[i].trimmed) { - // check to see ifthe sprite ha been trimmed.. - if (frameData[i].trimmed) { + var texture = PIXI.TextureCache[i]; + + var actualSize = frameData[i].sourceSize; + var realSize = frameData[i].spriteSourceSize; - var texture = PIXI.TextureCache[i]; - - var actualSize = frameData[i].sourceSize; - var realSize = frameData[i].spriteSourceSize; - - texture.trim = new PIXI.Rectangle(realSize.x, realSize.y, actualSize.w, actualSize.h); - } - } + texture.trim = new PIXI.Rectangle(realSize.x, realSize.y, actualSize.w, actualSize.h); } - - image.load(); - - } - else if(this.json.bones) - { - // spine animation - var spineJsonParser = new spine.SkeletonJson(); - var skeletonData = spineJsonParser.readSkeletonData(this.json); - PIXI.AnimCache[this.url] = skeletonData; - this.onLoaded(); - } - else - { - this.onLoaded(); } } - else - { - this.onError(); - } + + image.load(); + } + else if(this.json.bones) + { + // spine animation + var spineJsonParser = new spine.SkeletonJson(); + var skeletonData = spineJsonParser.readSkeletonData(this.json); + PIXI.AnimCache[this.url] = skeletonData; + this.onLoaded(); + } + else + { + this.onLoaded(); + } + // } + // else + //{ + // this.onError(); + // / } + // } }; /** diff --git a/src/pixi/loaders/JsonLoader.js b/src/pixi/loaders/JsonLoader.js index c50be0a..815e2d4 100644 --- a/src/pixi/loaders/JsonLoader.js +++ b/src/pixi/loaders/JsonLoader.js @@ -61,15 +61,40 @@ * @method load */ PIXI.JsonLoader.prototype.load = function () { - this.ajaxRequest = new PIXI.AjaxRequest(this.crossorigin); + + + if(window.XDomainRequest) + { + this.ajaxRequest = new window.XDomainRequest(); + } + else if (window.XMLHttpRequest) + { + this.ajaxRequest = new window.XMLHttpRequest(); + } + else + { + this.ajaxRequest = new window.ActiveXObject('Microsoft.XMLHTTP'); + } + + + + + // this.ajaxRequest = new PIXI.AjaxRequest(this.crossorigin); var scope = this; - this.ajaxRequest.onreadystatechange = function () { + + + + + this.ajaxRequest.onload = function () { scope.onJSONLoaded(); }; - this.ajaxRequest.open('GET', this.url, true); - if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType('application/json'); - this.ajaxRequest.send(null); + // this.ajaxRequest.open('GET', this.url, true); + // if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType('application/json'); + // this.ajaxRequest.send(null); + + this.ajaxRequest.open('GET',this.url,false); + this.ajaxRequest.send(); }; /** @@ -79,67 +104,67 @@ * @private */ PIXI.JsonLoader.prototype.onJSONLoaded = function () { - if (this.ajaxRequest.readyState === 4) { - if (this.ajaxRequest.status === 200 || window.location.protocol.indexOf('http') === -1) { - this.json = JSON.parse(this.ajaxRequest.responseText); + // if (this.ajaxRequest.readyState === 4) { + // if (this.ajaxRequest.status === 200 || window.location.protocol.indexOf('http') === -1) { + this.json = JSON.parse(this.ajaxRequest.responseText); - if(this.json.frames) - { - // sprite sheet - var scope = this; - var textureUrl = this.baseUrl + this.json.meta.image; - var image = new PIXI.ImageLoader(textureUrl, this.crossorigin); - var frameData = this.json.frames; + if(this.json.frames) + { + // sprite sheet + var scope = this; + var textureUrl = this.baseUrl + this.json.meta.image; + var image = new PIXI.ImageLoader(textureUrl, this.crossorigin); + var frameData = this.json.frames; - this.texture = image.texture.baseTexture; - image.addEventListener('loaded', function() { - scope.onLoaded(); + this.texture = image.texture.baseTexture; + image.addEventListener('loaded', function() { + scope.onLoaded(); + }); + + for (var i in frameData) { + var rect = frameData[i].frame; + if (rect) { + PIXI.TextureCache[i] = new PIXI.Texture(this.texture, { + x: rect.x, + y: rect.y, + width: rect.w, + height: rect.h }); - for (var i in frameData) { - var rect = frameData[i].frame; - if (rect) { - PIXI.TextureCache[i] = new PIXI.Texture(this.texture, { - x: rect.x, - y: rect.y, - width: rect.w, - height: rect.h - }); + // check to see ifthe sprite ha been trimmed.. + if (frameData[i].trimmed) { - // check to see ifthe sprite ha been trimmed.. - if (frameData[i].trimmed) { + var texture = PIXI.TextureCache[i]; + + var actualSize = frameData[i].sourceSize; + var realSize = frameData[i].spriteSourceSize; - var texture = PIXI.TextureCache[i]; - - var actualSize = frameData[i].sourceSize; - var realSize = frameData[i].spriteSourceSize; - - texture.trim = new PIXI.Rectangle(realSize.x, realSize.y, actualSize.w, actualSize.h); - } - } + texture.trim = new PIXI.Rectangle(realSize.x, realSize.y, actualSize.w, actualSize.h); } - - image.load(); - - } - else if(this.json.bones) - { - // spine animation - var spineJsonParser = new spine.SkeletonJson(); - var skeletonData = spineJsonParser.readSkeletonData(this.json); - PIXI.AnimCache[this.url] = skeletonData; - this.onLoaded(); - } - else - { - this.onLoaded(); } } - else - { - this.onError(); - } + + image.load(); + } + else if(this.json.bones) + { + // spine animation + var spineJsonParser = new spine.SkeletonJson(); + var skeletonData = spineJsonParser.readSkeletonData(this.json); + PIXI.AnimCache[this.url] = skeletonData; + this.onLoaded(); + } + else + { + this.onLoaded(); + } + // } + // else + //{ + // this.onError(); + // / } + // } }; /** diff --git a/src/pixi/text/Text.js b/src/pixi/text/Text.js index 16a9294..17716ac 100644 --- a/src/pixi/text/Text.js +++ b/src/pixi/text/Text.js @@ -130,11 +130,18 @@ lineWidths[i] = lineWidth; maxLineWidth = Math.max(maxLineWidth, lineWidth); } - this.canvas.width = maxLineWidth + this.style.strokeThickness; + var width = maxLineWidth + this.style.strokeThickness; + if(this.style.dropShadow)width += this.style.dropShadowDistance; + + this.canvas.width = width; //calculate text height var lineHeight = this.determineFontHeight('font: ' + this.style.font + ';') + this.style.strokeThickness; - this.canvas.height = lineHeight * lines.length; + + var height = lineHeight * lines.length; + if(this.style.dropShadow)height += this.style.dropShadowDistance; + + this.canvas.height = height; if(navigator.isCocoonJS) this.context.clearRect(0,0,this.canvas.width,this.canvas.height);