PIXI.TextureSilentFail is a boolean that defaults to false. If true then PIXI.Texture.setFrame will no longer throw an error if the texture dimensions are incorrect. Instead Texture.valid will be set to false (#1556)

This commit is contained in:
photonstorm 2015-02-11 22:10:53 +00:00
parent daf8440247
commit b692d3b456
2 changed files with 17 additions and 1 deletions

View file

@ -129,6 +129,7 @@ Thanks to @pnstickne for vast majority of this update.
* Loader.audiosprite has a new `jsonData` parameter. It allows you to pass a pre-existing JSON object (or a string which will be parsed as JSON) to use as the audiosprite data, instead of specifying a URL to a JSON file on the server (thanks @jounii #1447) * Loader.audiosprite has a new `jsonData` parameter. It allows you to pass a pre-existing JSON object (or a string which will be parsed as JSON) to use as the audiosprite data, instead of specifying a URL to a JSON file on the server (thanks @jounii #1447)
* Loader.audiosprite has a new `autoDecode` parameter. If `true` the audio file will be decoded immediately upon load. * Loader.audiosprite has a new `autoDecode` parameter. If `true` the audio file will be decoded immediately upon load.
* Tile.properties is now unique to that specific Tile, and not a reference to the Tileset index bound properties object. Tile.properties can now be modified freely without impacting other tiles sharing the same id (#1254) * Tile.properties is now unique to that specific Tile, and not a reference to the Tileset index bound properties object. Tile.properties can now be modified freely without impacting other tiles sharing the same id (#1254)
* PIXI.TextureSilentFail is a boolean that defaults to `false`. If `true` then `PIXI.Texture.setFrame` will no longer throw an error if the texture dimensions are incorrect. Instead `Texture.valid` will be set to `false` (#1556)
### Bug Fixes ### Bug Fixes

View file

@ -5,6 +5,15 @@
PIXI.TextureCache = {}; PIXI.TextureCache = {};
PIXI.FrameCache = {}; PIXI.FrameCache = {};
/**
* TextureSilentFail is a boolean that defaults to `false`.
* If `true` then `PIXI.Texture.setFrame` will no longer throw an error if the texture dimensions are incorrect.
* Instead `Texture.valid` will be set to `false` (#1556)
*
* @type {boolean}
*/
PIXI.TextureSilentFail = false;
PIXI.TextureCacheIdGenerator = 0; PIXI.TextureCacheIdGenerator = 0;
/** /**
@ -180,7 +189,13 @@ PIXI.Texture.prototype.setFrame = function(frame)
if (!this.trim && (frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height)) if (!this.trim && (frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height))
{ {
throw new Error('Texture Error: frame does not fit inside the base Texture dimensions ' + this); if (!PIXI.TextureSilentFail)
{
throw new Error('Texture Error: frame does not fit inside the base Texture dimensions ' + this);
}
this.valid = false;
return;
} }
this.valid = frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded; this.valid = frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded;