2016-10-04 14:39:54 +00:00
|
|
|
/**
|
|
|
|
* Note that 'this' in all functions here refer to the owning object.
|
|
|
|
* For example the Group, Stage, Sprite, etc. because the render function
|
|
|
|
* here is mapped to the prototype for the game object.
|
|
|
|
*/
|
|
|
|
Phaser.Renderer.WebGL.GameObjects.Container = {
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
TYPES: [
|
|
|
|
Phaser.Group.prototype,
|
|
|
|
PIXI.DisplayObjectContainer.prototype
|
|
|
|
],
|
|
|
|
|
|
|
|
render: function (renderer, src)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src.visible === false || src.alpha === 0 || src.children.length === 0)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._cacheAsBitmap)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
return Phaser.Renderer.WebGL.GameObjects.Container.renderCachedSprite(renderer, src);
|
2016-10-04 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var i;
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._mask || src._filters)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
|
|
|
// push filter first as we need to ensure the stencil buffer is correct for any masking
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._filters)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
|
|
|
renderer.spriteBatch.flush();
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.filterManager.pushFilter(src._filterBlock);
|
2016-10-04 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._mask)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
|
|
|
renderer.spriteBatch.stop();
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.pushMask(src.mask);
|
2016-10-04 14:39:54 +00:00
|
|
|
renderer.spriteBatch.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
// simple render children!
|
2016-10-05 00:25:06 +00:00
|
|
|
for (i = 0; i < src.children.length; i++)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
var child = src.children[i];
|
|
|
|
child.render(renderer, child);
|
2016-10-04 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderer.spriteBatch.stop();
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._mask)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.popMask(src._mask);
|
2016-10-04 14:39:54 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._filters)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
|
|
|
renderer.filterManager.popFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer.spriteBatch.start();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// simple render children!
|
2016-10-05 00:25:06 +00:00
|
|
|
for (i = 0; i < src.children.length; i++)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
var child = src.children[i];
|
|
|
|
child.render(renderer, child);
|
2016-10-04 14:39:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
renderCachedSprite: function (renderer, src)
|
2016-10-04 14:39:54 +00:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|