diff --git a/src/game/lib/back_button.js b/src/game/lib/back_button.js index 748eba1..a67ce3e 100644 --- a/src/game/lib/back_button.js +++ b/src/game/lib/back_button.js @@ -2,6 +2,8 @@ class BackButton { constructor(clickEvent) { let setting = new RoundRectButtonSetting(50, 50); + setting.fontStyle.boundsAlignH = "center"; // left, center. right + setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom setting.setStrokeColor( 0x884444, 0xaa6666, diff --git a/src/game/lib/round_rect_button.js b/src/game/lib/round_rect_button.js index 9b2ae6c..04273d6 100644 --- a/src/game/lib/round_rect_button.js +++ b/src/game/lib/round_rect_button.js @@ -123,6 +123,7 @@ class RoundRectButton { let width = this.setting.width - this.setting.strokeWidth * 2; let height = this.setting.height - this.setting.strokeWidth * 2; let innerRoundAmount = this.setting.roundAmount * (width / this.setting.width); + let btnTexture = new Phaser.Graphics() .beginFill(0xffffff) .drawRoundedRect(this.setting.strokeWidth, this.setting.strokeWidth, width, height, innerRoundAmount) @@ -133,8 +134,11 @@ class RoundRectButton { } makeText(textContent) { + let width = this.setting.width - this.setting.strokeWidth * 2; + let height = this.setting.height - this.setting.strokeWidth * 2; + let btnText = game.add.text(0, 0, textContent, this.setting.fontStyle) - .setTextBounds(0, 0, this.setting.width, this.setting.height); + .setTextBounds(0, 0, width, this.setting.height); btnText.lineSpacing = RoundRectButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX; // btnText.anchor.setTo(0.5);