Don't draw text only when width or height is 0

It can fix this issue:
Text is empty string '', but have fixedWidth and fixedHeight, with backgroundColor setting.
This commit is contained in:
Rex 2019-05-26 20:58:40 +08:00
parent cc7870906b
commit 9a958631fc
3 changed files with 6 additions and 4 deletions

View file

@ -185,7 +185,7 @@ var Text = new Class({
* @private
* @since 3.12.0
*/
this._text = '';
this._text = undefined;
/**
* Specify a padding value which is added to the line width and height when calculating the Text size.

View file

@ -21,10 +21,12 @@
*/
var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
{
if (src.text !== '')
if ((src.width === 0) || (src.height === 0))
{
renderer.batchSprite(src, src.frame, camera, parentMatrix);
return;
}
renderer.batchSprite(src, src.frame, camera, parentMatrix);
};
module.exports = TextCanvasRenderer;

View file

@ -23,7 +23,7 @@ var Utils = require('../../../renderer/webgl/Utils');
*/
var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
{
if (src.text === '')
if ((src.width === 0) || (src.height === 0))
{
return;
}