Fix: button text align
This commit is contained in:
@@ -2,6 +2,8 @@ class BackButton {
|
|||||||
|
|
||||||
constructor(clickEvent) {
|
constructor(clickEvent) {
|
||||||
let setting = new RoundRectButtonSetting(50, 50);
|
let setting = new RoundRectButtonSetting(50, 50);
|
||||||
|
setting.fontStyle.boundsAlignH = "center"; // left, center. right
|
||||||
|
setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom
|
||||||
setting.setStrokeColor(
|
setting.setStrokeColor(
|
||||||
0x884444,
|
0x884444,
|
||||||
0xaa6666,
|
0xaa6666,
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ class RoundRectButton {
|
|||||||
let width = this.setting.width - this.setting.strokeWidth * 2;
|
let width = this.setting.width - this.setting.strokeWidth * 2;
|
||||||
let height = this.setting.height - this.setting.strokeWidth * 2;
|
let height = this.setting.height - this.setting.strokeWidth * 2;
|
||||||
let innerRoundAmount = this.setting.roundAmount * (width / this.setting.width);
|
let innerRoundAmount = this.setting.roundAmount * (width / this.setting.width);
|
||||||
|
|
||||||
let btnTexture = new Phaser.Graphics()
|
let btnTexture = new Phaser.Graphics()
|
||||||
.beginFill(0xffffff)
|
.beginFill(0xffffff)
|
||||||
.drawRoundedRect(this.setting.strokeWidth, this.setting.strokeWidth, width, height, innerRoundAmount)
|
.drawRoundedRect(this.setting.strokeWidth, this.setting.strokeWidth, width, height, innerRoundAmount)
|
||||||
@@ -133,8 +134,11 @@ class RoundRectButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
makeText(textContent) {
|
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)
|
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.lineSpacing = RoundRectButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX;
|
||||||
// btnText.anchor.setTo(0.5);
|
// btnText.anchor.setTo(0.5);
|
||||||
|
|||||||
Reference in New Issue
Block a user