Fix: button text align

This commit is contained in:
2018-05-07 10:42:37 +09:00
parent 5d95abf86e
commit 3634e2bf01
2 changed files with 7 additions and 1 deletions
+2
View File
@@ -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,
+5 -1
View File
@@ -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);