diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index dd48cba..41d27d8 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -81,7 +81,7 @@ data.originalRenderCanvas = this.renderCanvas; data.originalUpdateTransform = this.updateTransform; - data.originalCalculateBounds = this._calculateBounds; + data.originalCalculateBounds = this.calculateBounds; data.originalGetLocalBounds = this.getLocalBounds; data.originalDestroy = this.destroy; @@ -107,7 +107,7 @@ this.renderWebGL = data.originalRenderWebGL; this.renderCanvas = data.originalRenderCanvas; - this._calculateBounds = data.originalCalculateBounds; + this.calculateBounds = data.originalCalculateBounds; this.getLocalBounds = data.originalGetLocalBounds; this.destroy = data.originalDestroy; @@ -219,7 +219,10 @@ renderer.filterManager.filterStack = stack; this.renderWebGL = this._renderCachedWebGL; + // the rest is the same as for Canvas this.updateTransform = this.displayObjectUpdateTransform; + this.calculateBounds = this._calculateCachedBounds; + this.getLocalBounds = this._getCachedLocalBounds; this._mask = null; this.filterArea = null; @@ -233,10 +236,6 @@ cachedSprite.alpha = cacheAlpha; cachedSprite._bounds = this._bounds; - // easy bounds.. - this._calculateBounds = this._calculateCachedBounds; - this.getLocalBounds = this._getCachedLocalBounds; - this._cacheData.sprite = cachedSprite; this.transform._parentID = -1; @@ -331,7 +330,10 @@ renderer.context = cachedRenderTarget; this.renderCanvas = this._renderCachedCanvas; + // the rest is the same as for WebGL + this.updateTransform = this.displayObjectUpdateTransform; this.calculateBounds = this._calculateCachedBounds; + this.getLocalBounds = this._getCachedLocalBounds; this._mask = null; this.filterArea = null; @@ -342,9 +344,13 @@ cachedSprite.transform.worldTransform = this.transform.worldTransform; cachedSprite.anchor.x = -(bounds.x / bounds.width); cachedSprite.anchor.y = -(bounds.y / bounds.height); - cachedSprite._bounds = this._bounds; cachedSprite.alpha = cacheAlpha; + cachedSprite._bounds = this._bounds; + this._cacheData.sprite = cachedSprite; + + this.transform._parentID = -1; + // restore the transform of the cached sprite to avoid the nasty flicker.. if (!this.parent) { this.parent = renderer._tempDisplayObjectParent; @@ -356,10 +362,7 @@ this.updateTransform(); } - this.updateTransform = this.displayObjectUpdateTransform; - - this._cacheData.sprite = cachedSprite; - + // map the hit test.. this.containsPoint = cachedSprite.containsPoint.bind(cachedSprite); };