The BitmapText.getTextBounds method was being called every frame, even if the bounds didn't change, potentially costing a lot of CPU depending on the text length and quantity of them. It now only updates the bounds if they change.

This commit is contained in:
Richard Davey 2020-07-30 14:46:32 +01:00
parent ffc180c14d
commit 841389628e

View file

@ -358,7 +358,7 @@ var BitmapText = new Class({
* @method Phaser.GameObjects.BitmapText#getTextBounds
* @since 3.0.0
*
* @param {boolean} [round] - Whether to round the results to the nearest integer.
* @param {boolean} [round=false] - Whether to round the results up to the nearest integer.
*
* @return {Phaser.Types.GameObjects.BitmapText.BitmapTextSize} An object that describes the size of this Bitmap Text.
*/
@ -372,10 +372,10 @@ var BitmapText = new Class({
if (this._dirty || this.scaleX !== bounds.scaleX || this.scaleY !== bounds.scaleY)
{
GetBitmapTextSize(this, round, bounds);
this._dirty = false;
GetBitmapTextSize(this, round, bounds);
this.updateDisplayOrigin();
}
@ -396,8 +396,6 @@ var BitmapText = new Class({
this._displayOriginX = this.originX * this.width;
this._displayOriginY = this.originY * this.height;
this._dirty = true;
return this;
},