2016-10-04 21:36:07 +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.Text = {
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
TYPES: [
|
2016-10-09 21:27:58 +00:00
|
|
|
Phaser.GameObject.Text.prototype
|
2016-10-05 00:25:06 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
render: function (renderer, src)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src.dirty)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
src.updateText();
|
|
|
|
src.dirty = false;
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the sprite is not visible or the alpha is 0 then no need to render this element
|
2016-10-05 00:25:06 +00:00
|
|
|
if (!src.visible || src.alpha === 0 || !src.renderable)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add back in: || src.texture.crop.width <= 0 || src.texture.crop.height <= 0
|
|
|
|
|
|
|
|
var i;
|
|
|
|
|
|
|
|
// Would be good to get this down to 1 check, or even none.
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._mask || src._filters)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
|
|
|
var spriteBatch = renderer.spriteBatch;
|
|
|
|
|
|
|
|
// 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 21:36:07 +00:00
|
|
|
{
|
|
|
|
spriteBatch.flush();
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.filterManager.pushFilter(src._filterBlock);
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._mask)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
|
|
|
spriteBatch.stop();
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.pushMask(src.mask);
|
2016-10-04 21:36:07 +00:00
|
|
|
spriteBatch.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
// add this sprite to the batch
|
2016-10-05 00:25:06 +00:00
|
|
|
spriteBatch.render(src);
|
2016-10-04 21:36:07 +00:00
|
|
|
|
|
|
|
// now loop through the children and make sure they get rendered
|
2016-10-05 00:25:06 +00:00
|
|
|
for (i = 0; i < src.children.length; i++)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
var child = src.children[i];
|
|
|
|
child.render(renderer, child);
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// time to stop the sprite batch as either a mask element or a filter draw will happen next
|
|
|
|
spriteBatch.stop();
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._mask)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.popMask(src._mask);
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 00:25:06 +00:00
|
|
|
if (src._filters)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
|
|
|
renderer.filterManager.popFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
spriteBatch.start();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
renderer.spriteBatch.render(src);
|
2016-10-04 21:36:07 +00:00
|
|
|
|
|
|
|
// Render children!
|
2016-10-05 00:25:06 +00:00
|
|
|
for (i = 0; i < src.children.length; i++)
|
2016-10-04 21:36:07 +00:00
|
|
|
{
|
2016-10-05 00:25:06 +00:00
|
|
|
var child = src.children[i];
|
|
|
|
child.render(renderer, child);
|
2016-10-04 21:36:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|