File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ] ) ;
You can’t perform that action at this time.
0 commit comments