add fromImage to BaseTexture
This commit is contained in:
parent
7a59ba7a23
commit
17f8260b5e
2 changed files with 18 additions and 17 deletions
|
@ -86,7 +86,20 @@ PIXI.BaseTexture = function(source)
|
|||
|
||||
PIXI.BaseTexture.constructor = PIXI.BaseTexture;
|
||||
|
||||
PIXI.BaseTexture.prototype.fromImage = function(imageUrl)
|
||||
PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin)
|
||||
{
|
||||
var baseTexture = PIXI.BaseTextureCache[imageUrl];
|
||||
if(!baseTexture)
|
||||
{
|
||||
var image = new Image();
|
||||
if (crossorigin)
|
||||
{
|
||||
image.crossOrigin = '';
|
||||
}
|
||||
image.src = imageUrl;
|
||||
baseTexture = new PIXI.BaseTexture(image);
|
||||
PIXI.BaseTextureCache[imageUrl] = baseTexture;
|
||||
}
|
||||
|
||||
return baseTexture;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ PIXI.Texture = function(baseTexture, frame)
|
|||
}
|
||||
|
||||
this.trim = new PIXI.Point();
|
||||
|
||||
if(baseTexture instanceof PIXI.Texture)
|
||||
baseTexture = baseTexture.baseTexture;
|
||||
|
||||
/**
|
||||
* The base texture of this texture
|
||||
|
@ -105,24 +108,9 @@ PIXI.Texture.fromImage = function(imageUrl, crossorigin)
|
|||
|
||||
if(!texture)
|
||||
{
|
||||
var baseTexture = PIXI.BaseTextureCache[imageUrl];
|
||||
if(!baseTexture)
|
||||
{
|
||||
var image = new Image();//new Image();
|
||||
if (crossorigin)
|
||||
{
|
||||
image.crossOrigin = '';
|
||||
}
|
||||
image.src = imageUrl;
|
||||
baseTexture = new PIXI.BaseTexture(image);
|
||||
PIXI.BaseTextureCache[imageUrl] = baseTexture;
|
||||
}
|
||||
texture = new PIXI.Texture(baseTexture);
|
||||
|
||||
texture = new PIXI.Texture(PIXI.BaseTexture.fromImage(imageUrl, crossorigin));
|
||||
|
||||
PIXI.TextureCache[imageUrl] = texture;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return texture;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue