Skip to content

Commit d931ced

Browse files
committed
Fixed issue with long text dropping to be shorter again.
1 parent 697a3f4 commit d931ced

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/gameobjects/BitmapText.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,16 +358,22 @@ Phaser.BitmapText.prototype.updateText = function () {
358358
var charCode = line.text.charCodeAt(c);
359359
var charData = data.chars[charCode];
360360

361-
var g = this.children[t];
361+
var g = this._glyphs[t];
362362

363363
if (g)
364364
{
365+
// Sprite already exists in the glyphs pool, so we'll reuse it for this letter
365366
g.texture = charData.texture;
367+
// g.name = line.text[c];
368+
// console.log('reusing', g.name, 'as', line.text[c]);
366369
}
367370
else
368371
{
372+
// We need a new sprite as the pool is empty or exhausted
369373
g = new PIXI.Sprite(charData.texture);
374+
g.name = line.text[c];
370375
this._glyphs.push(g);
376+
// console.log('new', line.text[c]);
371377
}
372378

373379
g.position.x = (line.chars[c] + align) - ax;
@@ -386,6 +392,7 @@ Phaser.BitmapText.prototype.updateText = function () {
386392
}
387393

388394
// Remove unnecessary children
395+
// This moves them from the display list (children array) but retains them in the _glyphs pool
389396
for (i = t; i < this._glyphs.length; i++)
390397
{
391398
this.removeChild(this._glyphs[i]);

0 commit comments

Comments
 (0)