Skip to content

Commit 9a95863

Browse files
committed
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.
1 parent cc78709 commit 9a95863

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/gameobjects/text/static/Text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ var Text = new Class({
185185
* @private
186186
* @since 3.12.0
187187
*/
188-
this._text = '';
188+
this._text = undefined;
189189

190190
/**
191191
* Specify a padding value which is added to the line width and height when calculating the Text size.

src/gameobjects/text/static/TextCanvasRenderer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
*/
2222
var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
2323
{
24-
if (src.text !== '')
24+
if ((src.width === 0) || (src.height === 0))
2525
{
26-
renderer.batchSprite(src, src.frame, camera, parentMatrix);
26+
return;
2727
}
28+
29+
renderer.batchSprite(src, src.frame, camera, parentMatrix);
2830
};
2931

3032
module.exports = TextCanvasRenderer;

src/gameobjects/text/static/TextWebGLRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var Utils = require('../../../renderer/webgl/Utils');
2323
*/
2424
var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
2525
{
26-
if (src.text === '')
26+
if ((src.width === 0) || (src.height === 0))
2727
{
2828
return;
2929
}

0 commit comments

Comments
 (0)