diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index a8a28f8..6d23345 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -381,6 +381,7 @@ if(!this.parent) { this.parent = _tempDisplayObjectParent; + this.parent.transform._worldID++; this.updateTransform(); this.parent = null; } diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index a8a28f8..6d23345 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -381,6 +381,7 @@ if(!this.parent) { this.parent = _tempDisplayObjectParent; + this.parent.transform._worldID++; this.updateTransform(); this.parent = null; } diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 2957e70..6fb0b07 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -353,15 +353,34 @@ * */ -Sprite.prototype.getLocalBounds = function () +Sprite.prototype.getLocalBounds = function (rect) { + // we can do a fast local bounds if the sprite has no children! + if(this.children.length === 0) + { - this._bounds.minX = -this._texture.orig.width * this.anchor.x; - this._bounds.minY = -this._texture.orig.height * this.anchor.y; - this._bounds.maxX = this._texture.orig.width; - this._bounds.maxY = this._texture.orig.height; + this._bounds.minX = -this._texture.orig.width * this.anchor.x; + this._bounds.minY = -this._texture.orig.height * this.anchor.y; + this._bounds.maxX = this._texture.orig.width; + this._bounds.maxY = this._texture.orig.height; - return this._bounds.getRectangle(this._bounds); + if(!rect) + { + if(!this._localBoundsRect) + { + this._localBoundsRect = new math.Rectangle(); + } + + rect = this._localBoundsRect; + } + + return this._bounds.getRectangle(rect); + } + else + { + return DisplayObject.prototype.getLocalBounds.call(this, rect); + } + }; /** diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index a8a28f8..6d23345 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -381,6 +381,7 @@ if(!this.parent) { this.parent = _tempDisplayObjectParent; + this.parent.transform._worldID++; this.updateTransform(); this.parent = null; } diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 2957e70..6fb0b07 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -353,15 +353,34 @@ * */ -Sprite.prototype.getLocalBounds = function () +Sprite.prototype.getLocalBounds = function (rect) { + // we can do a fast local bounds if the sprite has no children! + if(this.children.length === 0) + { - this._bounds.minX = -this._texture.orig.width * this.anchor.x; - this._bounds.minY = -this._texture.orig.height * this.anchor.y; - this._bounds.maxX = this._texture.orig.width; - this._bounds.maxY = this._texture.orig.height; + this._bounds.minX = -this._texture.orig.width * this.anchor.x; + this._bounds.minY = -this._texture.orig.height * this.anchor.y; + this._bounds.maxX = this._texture.orig.width; + this._bounds.maxY = this._texture.orig.height; - return this._bounds.getRectangle(this._bounds); + if(!rect) + { + if(!this._localBoundsRect) + { + this._localBoundsRect = new math.Rectangle(); + } + + rect = this._localBoundsRect; + } + + return this._bounds.getRectangle(rect); + } + else + { + return DisplayObject.prototype.getLocalBounds.call(this, rect); + } + }; /** diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index d90c8c6..bf2f405 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -168,10 +168,12 @@ // need to set // var m = _tempMatrix; - m.tx = -bounds.x; m.ty = -bounds.y; + // reset + this.transform.worldTransform.identity(); + // set all properties to there original so we can render to a texture this.renderWebGL = this._cacheData.originalRenderWebGL; @@ -197,6 +199,7 @@ this._cacheData.sprite = cachedSprite; + this.transform._parentID = -1; // restore the transform of the cached sprite to avoid the nasty flicker.. this.updateTransform();