Skip to content

Commit ea75c5c

Browse files
committed
Updated quad alpha checks
1 parent a7a15bc commit ea75c5c

2 files changed

Lines changed: 28 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ In combination these updates fix issues #4732 and #4672. My thanks to @BenjaminD
6868
* The Static Tilemap Canvas Renderer will now respect the game config anti-alias / pixel art settings and render accordingly.
6969
* The Dynamic Tilemap Canvas Renderer will now respect the game config anti-alias / pixel art settings and render accordingly.
7070
* All Game Objects that use the Canvas Set Transform function (which is most of them) will aos now respect the game config anti-alias / pixel art settings and render accordingly. This means you can now have properly scaled Bitmap Text, Text, Sprites, Render Textures, etc when pixel art is enabled in your game. Fix #4701 (thanks @agar3s)
71+
* Containers are now able to set the alpha quadrant values (topLeft, topRight, bottomLeft and bottomRight) and have these passed onto children which are capable of supporting them, such as Sprites. Fix #4714 (thanks @MrcSnm)
7172

7273
### Bug Fixes
7374

src/gameobjects/container/ContainerWebGLRenderer.js

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ var ContainerWebGLRenderer = function (renderer, container, interpolationPercent
5252
renderer.setBlendMode(0);
5353
}
5454

55-
var alpha = container._alpha;
55+
// var alpha = container._alpha;
5656

57+
var alphaTopLeft = container.alphaTopLeft;
5758
var alphaTopRight = container.alphaTopRight;
5859
var alphaBottomLeft = container.alphaBottomLeft;
5960
var alphaBottomRight = container.alphaBottomRight;
60-
var usingQuadAlpha = (alphaBottomLeft !== alpha || alphaBottomRight !== alpha || alphaTopRight !== alpha);
6161

6262
var scrollFactorX = container.scrollFactorX;
6363
var scrollFactorY = container.scrollFactorY;
@@ -75,11 +75,27 @@ var ContainerWebGLRenderer = function (renderer, container, interpolationPercent
7575
continue;
7676
}
7777

78-
var childAlpha = child.alpha;
79-
var childAlphaTopRight = child.alphaTopRight;
80-
var childAlphaBottomLeft = child.alphaBottomLeft;
81-
var childAlphaBottomRight = child.alphaBottomRight;
82-
var usingChildQuadAlpha = (childAlphaBottomLeft !== childAlpha || childAlphaBottomRight !== childAlpha || childAlphaTopRight !== childAlpha);
78+
var childAlphaTopLeft;
79+
var childAlphaTopRight;
80+
var childAlphaBottomLeft;
81+
var childAlphaBottomRight;
82+
83+
if (child.alphaTopLeft !== undefined)
84+
{
85+
childAlphaTopLeft = child.alphaTopLeft;
86+
childAlphaTopRight = child.alphaTopRight;
87+
childAlphaBottomLeft = child.alphaBottomLeft;
88+
childAlphaBottomRight = child.alphaBottomRight;
89+
}
90+
else
91+
{
92+
var childAlpha = child.alpha;
93+
94+
childAlphaTopLeft = childAlpha;
95+
childAlphaTopRight = childAlpha;
96+
childAlphaBottomLeft = childAlpha;
97+
childAlphaBottomRight = childAlpha;
98+
}
8399

84100
var childScrollFactorX = child.scrollFactorX;
85101
var childScrollFactorY = child.scrollFactorY;
@@ -118,38 +134,15 @@ var ContainerWebGLRenderer = function (renderer, container, interpolationPercent
118134
// Set parent values
119135
child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY);
120136

121-
if (usingQuadAlpha)
122-
{
123-
if (usingChildQuadAlpha)
124-
{
125-
child.setAlpha(childAlpha * alpha, childAlphaTopRight * alphaTopRight, childAlphaBottomLeft * alphaBottomLeft, childAlphaBottomRight * alphaBottomRight);
126-
}
127-
else
128-
{
129-
child.setAlpha(childAlpha * alpha, childAlpha * alphaTopRight, childAlpha * alphaBottomLeft, childAlpha * alphaBottomRight);
130-
}
131-
}
132-
else if (usingChildQuadAlpha)
133-
{
134-
child.setAlpha(childAlpha * alpha, childAlphaTopRight * alpha, childAlphaBottomLeft * alpha, childAlphaBottomRight * alpha);
135-
}
136-
else
137-
{
138-
child.setAlpha(childAlpha * alpha);
139-
}
137+
child.setAlpha(childAlphaTopLeft * alphaTopLeft, childAlphaTopRight * alphaTopRight, childAlphaBottomLeft * alphaBottomLeft, childAlphaBottomRight * alphaBottomRight);
140138

141139
// Render
142140
child.renderWebGL(renderer, child, interpolationPercentage, camera, transformMatrix);
143141

144142
// Restore original values
145-
if (usingChildQuadAlpha)
146-
{
147-
child.setAlpha(childAlpha, childAlphaTopRight, childAlphaBottomLeft, childAlphaBottomRight);
148-
}
149-
else
150-
{
151-
child.setAlpha(childAlpha);
152-
}
143+
144+
child.setAlpha(childAlphaTopLeft, childAlphaTopRight, childAlphaBottomLeft, childAlphaBottomRight);
145+
153146
child.setScrollFactor(childScrollFactorX, childScrollFactorY);
154147

155148
renderer.newType = false;

0 commit comments

Comments
 (0)