Fixed graphics bug + updated docs

Fixed issue with getBounds being incorrect for graphics
Updated docs
Linted code
This commit is contained in:
Mat Groves 2014-01-01 23:54:45 +00:00
parent 53506da65e
commit 7713731ab3
145 changed files with 15583 additions and 24078 deletions

View file

@ -19,7 +19,7 @@
</div>
<div class="yui3-u-1-4 version">
<em>API Docs for: 1.3.0</em>
<em>API Docs for: 1.4.0</em>
</div>
</div>
<div id="bd" class="yui3-g">
@ -45,6 +45,8 @@
<li><a href="../classes/AssetLoader.html">AssetLoader</a></li>
<li><a href="../classes/AtlasLoader.html">AtlasLoader</a></li>
<li><a href="../classes/BaseTexture.html">BaseTexture</a></li>
<li><a href="../classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
@ -61,7 +63,7 @@
<li><a href="../classes/ColorMatrixFilter.html">ColorMatrixFilter</a></li>
<li><a href="../classes/CustomRenderable.html">CustomRenderable</a></li>
<li><a href="../classes/ColorStepFilter.html">ColorStepFilter</a></li>
<li><a href="../classes/DisplacementFilter.html">DisplacementFilter</a></li>
@ -75,7 +77,7 @@
<li><a href="../classes/Graphics.html">Graphics</a></li>
<li><a href="../classes/GreyFilter.html">GreyFilter</a></li>
<li><a href="../classes/GrayFilter.html">GrayFilter</a></li>
<li><a href="../classes/ImageLoader.html">ImageLoader</a></li>
@ -87,6 +89,8 @@
<li><a href="../classes/PixelateFilter.html">PixelateFilter</a></li>
<li><a href="../classes/PIXI.PixiShader.html">PIXI.PixiShader</a></li>
<li><a href="../classes/Point.html">Point</a></li>
<li><a href="../classes/Polygon.html">Polygon</a></li>
@ -109,10 +113,10 @@
<li><a href="../classes/Spine.html">Spine</a></li>
<li><a href="../classes/Sprite.html">Sprite</a></li>
<li><a href="../classes/SpriteSheetLoader.html">SpriteSheetLoader</a></li>
<li><a href="../classes/Sprite™.html">Sprite™</a></li>
<li><a href="../classes/Stage.html">Stage</a></li>
<li><a href="../classes/Text.html">Text</a></li>
@ -121,8 +125,6 @@
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
<li><a href="../classes/WebGLBatch.html">WebGLBatch</a></li>
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
</ul>
@ -176,8 +178,8 @@
/**
* The json file loader is used to load in JSON data and parsing it
* When loaded this class will dispatch a &quot;loaded&quot; event
* If load failed this class will dispatch a &quot;error&quot; event
* When loaded this class will dispatch a &#x27;loaded&#x27; event
* If load failed this class will dispatch a &#x27;error&#x27; event
*
* @class JsonLoader
* @uses EventTarget
@ -186,41 +188,41 @@
* @param crossorigin {Boolean} Whether requests should be treated as crossorigin
*/
PIXI.JsonLoader = function (url, crossorigin) {
PIXI.EventTarget.call(this);
PIXI.EventTarget.call(this);
/**
* The url of the bitmap font data
*
* @property url
* @type String
*/
this.url = url;
/**
* The url of the bitmap font data
*
* @property url
* @type String
*/
this.url = url;
/**
* Whether the requests should be treated as cross origin
*
* @property crossorigin
* @type Boolean
*/
this.crossorigin = crossorigin;
/**
* Whether the requests should be treated as cross origin
*
* @property crossorigin
* @type Boolean
*/
this.crossorigin = crossorigin;
/**
* [read-only] The base url of the bitmap font data
*
* @property baseUrl
* @type String
* @readOnly
*/
this.baseUrl = url.replace(/[^\/]*$/, &quot;&quot;);
/**
* [read-only] The base url of the bitmap font data
*
* @property baseUrl
* @type String
* @readOnly
*/
this.baseUrl = url.replace(/[^\/]*$/, &#x27;&#x27;);
/**
* [read-only] Whether the data has loaded yet
*
* @property loaded
* @type Boolean
* @readOnly
*/
this.loaded = false;
/**
* [read-only] Whether the data has loaded yet
*
* @property loaded
* @type Boolean
* @readOnly
*/
this.loaded = false;
};
@ -233,15 +235,15 @@ PIXI.JsonLoader.prototype.constructor = PIXI.JsonLoader;
* @method load
*/
PIXI.JsonLoader.prototype.load = function () {
this.ajaxRequest = new AjaxRequest();
var scope = this;
this.ajaxRequest.onreadystatechange = function () {
scope.onJSONLoaded();
};
this.ajaxRequest = new PIXI.AjaxRequest();
var scope = this;
this.ajaxRequest.onreadystatechange = function () {
scope.onJSONLoaded();
};
this.ajaxRequest.open(&quot;GET&quot;, this.url, true);
if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType(&quot;application/json&quot;);
this.ajaxRequest.send(null);
this.ajaxRequest.open(&#x27;GET&#x27;, this.url, true);
if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType(&#x27;application/json&#x27;);
this.ajaxRequest.send(null);
};
/**
@ -251,62 +253,72 @@ PIXI.JsonLoader.prototype.load = function () {
* @private
*/
PIXI.JsonLoader.prototype.onJSONLoaded = function () {
if (this.ajaxRequest.readyState == 4) {
if (this.ajaxRequest.status == 200 || window.location.href.indexOf(&quot;http&quot;) == -1) {
this.json = JSON.parse(this.ajaxRequest.responseText);
if (this.ajaxRequest.readyState === 4) {
if (this.ajaxRequest.status === 200 || window.location.protocol.indexOf(&#x27;http&#x27;) === -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(&quot;loaded&quot;, function (event) {
scope.onLoaded();
});
this.texture = image.texture.baseTexture;
image.addEventListener(&#x27;loaded&#x27;, 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
});
if (frameData[i].trimmed) {
//var realSize = frameData[i].spriteSourceSize;
PIXI.TextureCache[i].realSize = frameData[i].spriteSourceSize;
PIXI.TextureCache[i].trim.x = 0; // (realSize.x / rect.w)
// calculate the offset!
}
}
}
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
});
image.load();
// check to see ifthe sprite ha been trimmed..
if (frameData[i].trimmed) {
}
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();
}
}
var texture = PIXI.TextureCache[i];
texture.trimmed = true;
var actualSize = frameData[i].sourceSize;
var realSize = frameData[i].spriteSourceSize;
texture.trim.x = realSize.x;
texture.trim.y = realSize.y;
texture.trim.realWidth = actualSize.w;
texture.trim.realHeight = 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();
}
}
};
/**
@ -316,11 +328,11 @@ PIXI.JsonLoader.prototype.onJSONLoaded = function () {
* @private
*/
PIXI.JsonLoader.prototype.onLoaded = function () {
this.loaded = true;
this.dispatchEvent({
type: &quot;loaded&quot;,
content: this
});
this.loaded = true;
this.dispatchEvent({
type: &#x27;loaded&#x27;,
content: this
});
};
/**
@ -330,10 +342,10 @@ PIXI.JsonLoader.prototype.onLoaded = function () {
* @private
*/
PIXI.JsonLoader.prototype.onError = function () {
this.dispatchEvent({
type: &quot;error&quot;,
content: this
});
this.dispatchEvent({
type: &#x27;error&#x27;,
content: this
});
};
</pre>
</div>