Protect against NaN rotation values

Throws an Error if a DisplayObject's rotation was set to NaN. Without this check, Sprite's textures could disappear silently, with no reference to the improper rotation value as the culprit.
This commit is contained in:
CacheFlowe 2014-02-02 10:54:48 -07:00
parent 9509f43163
commit 53ccc8128b

View file

@ -402,6 +402,9 @@ PIXI.DisplayObject.prototype.updateTransform = function()
// TODO OPTIMIZE THIS!! with dirty // TODO OPTIMIZE THIS!! with dirty
if(this.rotation !== this.rotationCache) if(this.rotation !== this.rotationCache)
{ {
if(isNaN(parseFloat(this.rotation)))
throw new Error('DisplayObject rotation values must be numeric.');
this.rotationCache = this.rotation; this.rotationCache = this.rotation;
this._sr = Math.sin(this.rotation); this._sr = Math.sin(this.rotation);
this._cr = Math.cos(this.rotation); this._cr = Math.cos(this.rotation);
@ -534,4 +537,4 @@ Object.defineProperty(PIXI.DisplayObject.prototype, 'y', {
set: function(value) { set: function(value) {
this.position.y = value; this.position.y = value;
} }
}); });