Container alpha added

This commit is contained in:
Felipe Alfonso 2018-04-09 12:32:08 -03:00
parent c2236e47eb
commit 9d39bd7b45
3 changed files with 16 additions and 2 deletions

View file

@ -36,6 +36,7 @@ var Container = new Class({
Extends: GameObject, Extends: GameObject,
Mixins: [ Mixins: [
Components.Alpha,
Components.BlendMode, Components.BlendMode,
Components.Depth, Components.Depth,
Components.Transform, Components.Transform,
@ -128,6 +129,7 @@ var Container = new Class({
this._displayList = scene.sys.displayList; this._displayList = scene.sys.displayList;
this.setPosition(x, y); this.setPosition(x, y);
this.clearAlpha();
if (Array.isArray(children)) if (Array.isArray(children))
{ {

View file

@ -45,9 +45,15 @@ var ContainerCanvasRenderer = function (renderer, container, interpolationPercen
transformMatrix.scale(container.scaleX, container.scaleY); transformMatrix.scale(container.scaleX, container.scaleY);
} }
var alpha = container._alpha;
for (var index = 0; index < children.length; ++index) for (var index = 0; index < children.length; ++index)
{ {
children[index].renderCanvas(renderer, children[index], interpolationPercentage, camera, transformMatrix); var child = children[index];
var childAlpha = child._alpha;
child.setAlpha(childAlpha * alpha);
child.renderCanvas(renderer, child, interpolationPercentage, camera, transformMatrix);
child.setAlpha(childAlpha);
} }
}; };

View file

@ -45,9 +45,15 @@ var ContainerWebGLRenderer = function (renderer, container, interpolationPercent
transformMatrix.scale(container.scaleX, container.scaleY); transformMatrix.scale(container.scaleX, container.scaleY);
} }
var alpha = container._alpha;
for (var index = 0; index < children.length; ++index) for (var index = 0; index < children.length; ++index)
{ {
children[index].renderWebGL(renderer, children[index], interpolationPercentage, camera, transformMatrix); var child = children[index];
var childAlpha = child._alpha;
child.setAlpha(childAlpha * alpha);
child.renderWebGL(renderer, child, interpolationPercentage, camera, transformMatrix);
child.setAlpha(childAlpha);
} }
}; };