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>
@ -126,6 +128,7 @@
PIXI.BaseTextureCache = {};
PIXI.texturesToUpdate = [];
PIXI.texturesToDestroy = [];
&#x2F;**
* A texture stores the information that represents an image. All textures have a base texture
@ -208,9 +211,43 @@ PIXI.BaseTexture = function(source)
PIXI.BaseTexture.constructor = PIXI.BaseTexture;
PIXI.BaseTexture.prototype.fromImage = function(imageUrl)
PIXI.BaseTexture.prototype.destroy = function()
{
if(this.source instanceof Image)
{
this.source.src = null;
}
this.source = null;
PIXI.texturesToDestroy.push(this);
}
&#x2F;**
*
* Helper function that returns a base texture based on an image url
* If the image is not in the base texture cache it will be created and loaded
* @static
* @method fromImage
* @param imageUrl {String} The image url of the texture
* @return BaseTexture
*&#x2F;
PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin)
{
var baseTexture = PIXI.BaseTextureCache[imageUrl];
if(!baseTexture)
{
var image = new Image();
if (crossorigin)
{
image.crossOrigin = &#x27;&#x27;;
}
image.src = imageUrl;
baseTexture = new PIXI.BaseTexture(image);
PIXI.BaseTextureCache[imageUrl] = baseTexture;
}
return baseTexture;
}
</pre>