Add: stroke and line spacing
This commit is contained in:
@@ -27,16 +27,19 @@ RoundRectButtonSetting.DEFAULT_BUTTON_COLORS = {
|
||||
|
||||
RoundRectButtonSetting.DEFAULT_TEXT_COLORS = {
|
||||
out: "#000",
|
||||
over: "#000",
|
||||
down: "#000",
|
||||
over: "#333",
|
||||
down: "#666",
|
||||
disabled: "#999"
|
||||
};
|
||||
|
||||
RoundRectButtonSetting.DEFAULT_TEXT_FONT = {
|
||||
font: "30px Arial",
|
||||
align: "center",
|
||||
fill: "#fff"
|
||||
};
|
||||
|
||||
RoundRectButtonSetting.DEFAULT_LINE_SPACING = -10; // pixels
|
||||
|
||||
|
||||
|
||||
class RoundRectButton {
|
||||
@@ -91,34 +94,37 @@ class RoundRectButton {
|
||||
makeText(textContent) {
|
||||
let btnText = game.add.text(0, 0, textContent, this.setting.fontStyle);
|
||||
btnText.anchor.setTo(0.5);
|
||||
btnText.lineSpacing = RoundRectButtonSetting.DEFAULT_LINE_SPACING;
|
||||
|
||||
return btnText;
|
||||
}
|
||||
|
||||
|
||||
move(x, y) {
|
||||
this.button.x = x;
|
||||
this.button.y = y;
|
||||
}
|
||||
|
||||
mouseOut() {
|
||||
this.button.tint = this.setting.buttonColors.out;
|
||||
this.text.tint = this.setting.textColors.out;
|
||||
this.text.fill = this.setting.textColors.out;
|
||||
}
|
||||
|
||||
mouseOver() {
|
||||
this.button.tint = this.setting.buttonColors.over;
|
||||
this.text.tint = this.setting.textColors.over;
|
||||
this.text.fill = this.setting.textColors.over;
|
||||
}
|
||||
|
||||
mouseDown() {
|
||||
this.button.tint = this.setting.buttonColors.down;
|
||||
this.text.tint = this.setting.textColors.down;
|
||||
this.text.fill = this.setting.textColors.down;
|
||||
}
|
||||
|
||||
buttonDisabled() {
|
||||
this.button.tint = this.setting.buttonColors.disabled;
|
||||
this.text.tint = this.setting.textColors.disabled;
|
||||
this.text.fill = this.setting.textColors.disabled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
move(x, y) {
|
||||
this.button.x = x;
|
||||
this.button.y = y;
|
||||
}
|
||||
|
||||
get inputEnabled() {
|
||||
@@ -134,6 +140,10 @@ class RoundRectButton {
|
||||
this.buttonDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
set lineSpacing(spacingInPixels) {
|
||||
this.text.lineSpacing = spacingInPixels;
|
||||
}
|
||||
}
|
||||
|
||||
RoundRectButton.defaultRoundAmount = 10;
|
||||
|
||||
Reference in New Issue
Block a user