Skip to content

Commit e7cce94

Browse files
author
=
committed
Container now can apply alpha quads
1 parent e0ec646 commit e7cce94

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

src/gameobjects/container/ContainerWebGLRenderer.js

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ var ContainerWebGLRenderer = function (renderer, container, interpolationPercent
5353
}
5454

5555
var alpha = container._alpha;
56+
57+
var alphaTopRight = container.alphaTopRight;
58+
var alphaBottomLeft = container.alphaBottomLeft;
59+
var alphaBottomRight = container.alphaBottomRight;
60+
var usingQuadAlpha = (alphaBottomLeft !== alpha || alphaBottomRight !== alpha || alphaTopRight !== alpha);
61+
5662
var scrollFactorX = container.scrollFactorX;
5763
var scrollFactorY = container.scrollFactorY;
5864

@@ -66,6 +72,11 @@ var ContainerWebGLRenderer = function (renderer, container, interpolationPercent
6672
}
6773

6874
var childAlpha = child.alpha;
75+
var childAlphaTopRight = child.alphaTopRight;
76+
var childAlphaBottomLeft = child.alphaBottomLeft;
77+
var childAlphaBottomRight = child.alphaBottomRight;
78+
var usingChildQuadAlpha = (childAlphaBottomLeft !== childAlpha || childAlphaBottomRight !== childAlpha || childAlphaTopRight !== childAlpha);
79+
6980
var childScrollFactorX = child.scrollFactorX;
7081
var childScrollFactorY = child.scrollFactorY;
7182

@@ -82,13 +93,42 @@ var ContainerWebGLRenderer = function (renderer, container, interpolationPercent
8293

8394
// Set parent values
8495
child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY);
85-
child.setAlpha(childAlpha * alpha);
96+
97+
if(usingQuadAlpha)
98+
{
99+
if(usingChildQuadAlpha)
100+
{
101+
child.setAlpha(childAlpha * alpha, childAlphaTopRight * alphaTopRight, childAlphaBottomLeft * alphaBottomLeft, childAlphaBottomRight * alphaBottomRight);
102+
}
103+
else
104+
{
105+
child.setAlpha(childAlpha * alpha, childAlpha * alphaTopRight, childAlpha * alphaBottomLeft, childAlpha * alphaBottomRight);
106+
}
107+
}
108+
else
109+
{
110+
if(usingChildQuadAlpha)
111+
{
112+
child.setAlpha(childAlpha * alpha, childAlphaTopRight * alpha, childAlphaBottomLeft * alpha, childAlphaBottomRight * alpha);
113+
}
114+
else
115+
{
116+
child.setAlpha(childAlpha * alpha);
117+
}
118+
}
86119

87120
// Render
88121
child.renderWebGL(renderer, child, interpolationPercentage, camera, transformMatrix);
89122

90123
// Restore original values
91-
child.setAlpha(childAlpha);
124+
if(usingChildQuadAlpha)
125+
{
126+
child.setAlpha(childAlpha, childAlphaTopRight, childAlphaBottomLeft, childAlphaBottomRight);
127+
}
128+
else
129+
{
130+
child.setAlpha(childAlpha);
131+
}
92132
child.setScrollFactor(childScrollFactorX, childScrollFactorY);
93133

94134
if (child.mask)

0 commit comments

Comments
 (0)