From 7fe9167657facb766f6b77727f51f1bd6e2ec50c Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Sun, 29 Jul 2018 12:23:52 +0100 Subject: [PATCH] The `alpha` value is now always set for Render Textures in canvas mode, regardless of the previous alpha value in the renderer --- .../RenderTextureCanvasRenderer.js | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js b/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js index 3767189ec..7ef8d607c 100644 --- a/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js +++ b/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js @@ -32,26 +32,6 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati // Nothing to see, so abort early return; } - else if (renderer.currentAlpha !== alpha) - { - renderer.currentAlpha = alpha; - ctx.globalAlpha = alpha; - } - - // Blend Mode - - if (renderer.currentBlendMode !== renderTexture.blendMode) - { - renderer.currentBlendMode = renderTexture.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; - } - - // Scale Mode - - if (renderer.currentScaleMode !== renderTexture.scaleMode) - { - renderer.currentScaleMode = renderTexture.scaleMode; - } var dx = 0; var dy = 0; @@ -81,6 +61,23 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati ctx.save(); + ctx.globalAlpha = alpha; + + // Blend Mode + + if (renderer.currentBlendMode !== renderTexture.blendMode) + { + renderer.currentBlendMode = renderTexture.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; + } + + // Scale Mode + + if (renderer.currentScaleMode !== renderTexture.scaleMode) + { + renderer.currentScaleMode = renderTexture.scaleMode; + } + if (parentMatrix !== undefined) { var matrix = parentMatrix.matrix; @@ -93,6 +90,7 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati ctx.scale(renderTexture.scaleX, renderTexture.scaleY); ctx.scale(fx, fy); ctx.drawImage(renderTexture.canvas, dx, dy); + ctx.restore(); };