Text added to PIXI

destroy function added to textures too
docs updated
new example added
This commit is contained in:
Mat Groves 2013-04-24 20:54:03 +01:00
parent 7933cadb77
commit 09dbbd5d13
66 changed files with 10970 additions and 681 deletions

View file

@ -67,6 +67,8 @@
<li><a href="..&#x2F;classes/Stage.html">Stage</a></li>
<li><a href="..&#x2F;classes/Text.html">Text</a></li>
<li><a href="..&#x2F;classes/Texture.html">Texture</a></li>
<li><a href="..&#x2F;classes/TilingSprite.html">TilingSprite</a></li>
@ -170,19 +172,17 @@ PIXI.Sprite = function(texture)
* @property width
* @type #Number
*&#x2F;
this.width = 0;
this._width = 0;
&#x2F;**
* The height of the sprite (this is initially set by the texture)
* @property height
* @type #Number
*&#x2F;
this.height = 0;
this._height = 0;
if(texture.baseTexture.hasLoaded)
{
this.width = this.texture.frame.width;
this.height = this.texture.frame.height;
this.updateFrame = true;
}
else
@ -202,6 +202,28 @@ PIXI.Sprite = function(texture)
PIXI.Sprite.constructor = PIXI.Sprite;
PIXI.Sprite.prototype = Object.create( PIXI.DisplayObjectContainer.prototype );
&#x2F;&#x2F; OOH! shiney new getters and setters for width and height
&#x2F;&#x2F; The width and height now modify the scale (this is what flash does, nice and tidy!)
Object.defineProperty(PIXI.Sprite.prototype, &#x27;width&#x27;, {
get: function() {
return this.scale.x * this.texture.frame.width;
},
set: function(value) {
this.scale.x = value &#x2F; this.texture.frame.width
this._width = value;
}
});
Object.defineProperty(PIXI.Sprite.prototype, &#x27;height&#x27;, {
get: function() {
return this.scale.y * this.texture.frame.height;
},
set: function(value) {
this.scale.y = value &#x2F; this.texture.frame.height
this._height = value;
}
});
&#x2F;**
@method setTexture
@param texture {Texture} The PIXI texture that is displayed by the sprite
@ -215,8 +237,6 @@ PIXI.Sprite.prototype.setTexture = function(texture)
}
this.texture = texture;
this.width = texture.frame.width;
this.height = texture.frame.height;
this.updateFrame = true;
}
@ -225,8 +245,12 @@ PIXI.Sprite.prototype.setTexture = function(texture)
*&#x2F;
PIXI.Sprite.prototype.onTextureUpdate = function(event)
{
this.width = this.width || this.texture.frame.width;
this.height = this.height || this.texture.frame.height;
&#x2F;&#x2F;this.texture.removeEventListener( &#x27;update&#x27;, this.onTextureUpdateBind );
&#x2F;&#x2F; so if _width is 0 then width was not set..
if(this._width)this.scale.x = this._width &#x2F; this.texture.frame.width;
if(this._height)this.scale.y = this._height &#x2F; this.texture.frame.height;
this.updateFrame = true;
}