Skip to content

Commit e097a12

Browse files
committed
Merge pull request phaserjs#2052 from nickryall/fix-for-text-centered-on-sprite
adjust wrapped text that is centered to sprite via anchor
2 parents 5f704f0 + ca795af commit e097a12

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/gameobjects/Text.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ Phaser.Text.prototype.updateText = function () {
364364
{
365365
// Simple layout (no tabs)
366366
var lineWidth = this.context.measureText(lines[i]).width + this.style.strokeThickness + this.padding.x;
367+
368+
// Adjust for wrapped text
369+
if (this.style.wordWrap)
370+
{
371+
lineWidth -= this.context.measureText(' ').width;
372+
}
367373
}
368374
else
369375
{

0 commit comments

Comments
 (0)