phaser/src/gameobjects/container/ContainerWebGLRenderer.js

83 lines
2 KiB
JavaScript
Raw Normal View History

/**
* 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-05 00:25:06 +00:00
if (src.visible === false || src.alpha === 0 || src.children.length === 0)
{
return;
}
2016-10-05 00:25:06 +00:00
if (src._cacheAsBitmap)
{
2016-10-05 00:25:06 +00:00
return Phaser.Renderer.WebGL.GameObjects.Container.renderCachedSprite(renderer, src);
}
var i;
2016-10-05 00:25:06 +00:00
if (src._mask || src._filters)
{
// 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)
{
renderer.spriteBatch.flush();
2016-10-05 00:25:06 +00:00
renderer.filterManager.pushFilter(src._filterBlock);
}
2016-10-05 00:25:06 +00:00
if (src._mask)
{
renderer.spriteBatch.stop();
2016-10-05 00:25:06 +00:00
renderer.pushMask(src.mask);
renderer.spriteBatch.start();
}
// simple render children!
2016-10-05 00:25:06 +00:00
for (i = 0; i < src.children.length; i++)
{
2016-10-05 00:25:06 +00:00
var child = src.children[i];
child.render(renderer, child);
}
renderer.spriteBatch.stop();
2016-10-05 00:25:06 +00:00
if (src._mask)
{
2016-10-05 00:25:06 +00:00
renderer.popMask(src._mask);
}
2016-10-05 00:25:06 +00:00
if (src._filters)
{
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-05 00:25:06 +00:00
var child = src.children[i];
child.render(renderer, child);
}
}
},
2016-10-05 00:25:06 +00:00
renderCachedSprite: function (renderer, src)
{
// TODO
return renderer;
}
};