Skip to content

Commit 7fc23c9

Browse files
committed
Text.setTextBounds didn't add the x and y values to the width and height offsets.
1 parent 1fed360 commit 7fc23c9

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
274274
* Removed use of the deprecated `enterFullScreen` and `leaveFullScreen` signals from the Scale Manager (thanks @mmanlod #1972)
275275
* BitmapText with tints applied wouldn't update properly in Canvas mode (thanks @Pajamaman #1969)
276276
* Group.cacheAsBitmap would be incorrectly offset in Canvas mode (thanks @mkristo #1925)
277-
277+
* Text.setTextBounds didn't add the x and y values to the width and height offsets.
278278

279279
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
280280

src/gameobjects/Text.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,20 +1129,20 @@ Phaser.Text.prototype.updateTexture = function () {
11291129
// Align the canvas based on the bounds
11301130
if (this.style.boundsAlignH === 'right')
11311131
{
1132-
x = this.textBounds.width - this.canvas.width;
1132+
x += this.textBounds.width - this.canvas.width;
11331133
}
11341134
else if (this.style.boundsAlignH === 'center')
11351135
{
1136-
x = this.textBounds.halfWidth - (this.canvas.width / 2);
1136+
x += this.textBounds.halfWidth - (this.canvas.width / 2);
11371137
}
11381138

11391139
if (this.style.boundsAlignV === 'bottom')
11401140
{
1141-
y = this.textBounds.height - this.canvas.height;
1141+
y += this.textBounds.height - this.canvas.height;
11421142
}
11431143
else if (this.style.boundsAlignV === 'middle')
11441144
{
1145-
y = this.textBounds.halfHeight - (this.canvas.height / 2);
1145+
y += this.textBounds.halfHeight - (this.canvas.height / 2);
11461146
}
11471147

11481148
this.pivot.x = -x;

0 commit comments

Comments
 (0)