Add: button shortcut text

This commit is contained in:
2018-10-16 11:47:34 +09:00
parent 7826f62a27
commit 9061ab54c3
4 changed files with 32 additions and 1 deletions
+2 -1
View File
@@ -25,7 +25,8 @@ function BackButton(clickEvent) {
"#333"
);
new RoundRectButton(setting, RoundRectButton.NONE_ICON, "<", clickEvent);
var backButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "<", clickEvent);
backButton.addShortcutText("ESC");
}
BackButton.prototype.startState = function(stateName) {
+28
View File
@@ -99,6 +99,9 @@ function RoundRectButton(roundRectSetting, iconName, buttonText, clickEvent) {
this.setIcon(this.icon);
}
this.shortcutText = this.makeShortcutText();
this.button.addChild(this.shortcutText);
// this.button.anchor.setTo(0.5, 0.5);
this.button.inputEnabled = true;
this.setEventMethod(this.button);
@@ -182,9 +185,28 @@ RoundRectButton.prototype.setIcon = function(icon) {
this.mouseOut();
}
RoundRectButton.prototype.makeShortcutText = function() {
var shortcutText = game.add.text(this.button.width / 2, this.button.height * 9 / 10, "");
shortcutText.anchor.set(0.5);
shortcutText.fontSize = this.button.height * 2 / 10;
// shortcutText.addColor(this.setting.textColors.over, 0);
shortcutText.addColor("0xffffff", 0);
return shortcutText;
}
RoundRectButton.prototype.addShortcutText = function(text) {
var scText = "[ " + text + " ]";
this.shortcutText.text = scText;
}
RoundRectButton.prototype.mouseOut = function() {
this.text.fill = this.setting.textColors.out;
if(this.shortcutText != undefined)
this.shortcutText.fill = this.setting.textColors.over;
this.buttonStroke.tint = this.setting.strokeColors.out;
this.button.tint = this.setting.buttonColors.out;
if(typeof this.buttonIcon !== "undefined") {
@@ -194,6 +216,8 @@ RoundRectButton.prototype.mouseOut = function() {
RoundRectButton.prototype.mouseOver = function() {
this.text.fill = this.setting.textColors.over;
if(this.shortcutText != undefined)
this.shortcutText.fill = this.setting.textColors.over;
this.buttonStroke.tint = this.setting.strokeColors.over;
this.button.tint = this.setting.buttonColors.over;
if(typeof this.buttonIcon !== "undefined") {
@@ -203,6 +227,8 @@ RoundRectButton.prototype.mouseOver = function() {
RoundRectButton.prototype.mouseDown = function() {
this.text.fill = this.setting.textColors.down;
if(this.shortcutText != undefined)
this.shortcutText.fill = this.setting.textColors.over;
this.buttonStroke.tint = this.setting.strokeColors.down;
this.button.tint = this.setting.buttonColors.down;
if(typeof this.buttonIcon !== "undefined") {
@@ -212,6 +238,8 @@ RoundRectButton.prototype.mouseDown = function() {
RoundRectButton.prototype.buttonDisabled = function() {
this.text.fill = this.setting.textColors.disabled;
if(this.shortcutText != undefined)
this.shortcutText.fill = this.setting.textColors.disabled;
this.buttonStroke.tint = this.setting.strokeColors.disabled;
this.button.tint = this.setting.buttonColors.disabled;
if(typeof this.buttonIcon !== "undefined") {
+1
View File
@@ -166,6 +166,7 @@ var Result = {
setting.fontStyle.fontWeight = "bold";
var startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "다시 시작", this.restartStage);
startButton.addShortcutText("Enter");
},
+1
View File
@@ -156,6 +156,7 @@ var Start = {
setting.fontStyle.fontWeight = "bold";
var startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "시작", this.startStage);
startButton.addShortcutText("Enter");
},
makeRankingButton: function() {