Add: button shortcut text
This commit is contained in:
1 parent
7826f62a27
commit
9061ab54c3
4 files changed
+32
-1
No files matched your search
@@ -25,7 +25,8 @@ function BackButton(clickEvent) {
|
|||||||
"#333"
|
"#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) {
|
BackButton.prototype.startState = function(stateName) {
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ function RoundRectButton(roundRectSetting, iconName, buttonText, clickEvent) {
|
|||||||
this.setIcon(this.icon);
|
this.setIcon(this.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.shortcutText = this.makeShortcutText();
|
||||||
|
this.button.addChild(this.shortcutText);
|
||||||
|
|
||||||
// this.button.anchor.setTo(0.5, 0.5);
|
// this.button.anchor.setTo(0.5, 0.5);
|
||||||
this.button.inputEnabled = true;
|
this.button.inputEnabled = true;
|
||||||
this.setEventMethod(this.button);
|
this.setEventMethod(this.button);
|
||||||
@@ -182,9 +185,28 @@ RoundRectButton.prototype.setIcon = function(icon) {
|
|||||||
this.mouseOut();
|
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() {
|
RoundRectButton.prototype.mouseOut = function() {
|
||||||
this.text.fill = this.setting.textColors.out;
|
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.buttonStroke.tint = this.setting.strokeColors.out;
|
||||||
this.button.tint = this.setting.buttonColors.out;
|
this.button.tint = this.setting.buttonColors.out;
|
||||||
if(typeof this.buttonIcon !== "undefined") {
|
if(typeof this.buttonIcon !== "undefined") {
|
||||||
@@ -194,6 +216,8 @@ RoundRectButton.prototype.mouseOut = function() {
|
|||||||
|
|
||||||
RoundRectButton.prototype.mouseOver = function() {
|
RoundRectButton.prototype.mouseOver = function() {
|
||||||
this.text.fill = this.setting.textColors.over;
|
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.buttonStroke.tint = this.setting.strokeColors.over;
|
||||||
this.button.tint = this.setting.buttonColors.over;
|
this.button.tint = this.setting.buttonColors.over;
|
||||||
if(typeof this.buttonIcon !== "undefined") {
|
if(typeof this.buttonIcon !== "undefined") {
|
||||||
@@ -203,6 +227,8 @@ RoundRectButton.prototype.mouseOver = function() {
|
|||||||
|
|
||||||
RoundRectButton.prototype.mouseDown = function() {
|
RoundRectButton.prototype.mouseDown = function() {
|
||||||
this.text.fill = this.setting.textColors.down;
|
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.buttonStroke.tint = this.setting.strokeColors.down;
|
||||||
this.button.tint = this.setting.buttonColors.down;
|
this.button.tint = this.setting.buttonColors.down;
|
||||||
if(typeof this.buttonIcon !== "undefined") {
|
if(typeof this.buttonIcon !== "undefined") {
|
||||||
@@ -212,6 +238,8 @@ RoundRectButton.prototype.mouseDown = function() {
|
|||||||
|
|
||||||
RoundRectButton.prototype.buttonDisabled = function() {
|
RoundRectButton.prototype.buttonDisabled = function() {
|
||||||
this.text.fill = this.setting.textColors.disabled;
|
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.buttonStroke.tint = this.setting.strokeColors.disabled;
|
||||||
this.button.tint = this.setting.buttonColors.disabled;
|
this.button.tint = this.setting.buttonColors.disabled;
|
||||||
if(typeof this.buttonIcon !== "undefined") {
|
if(typeof this.buttonIcon !== "undefined") {
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ var Result = {
|
|||||||
setting.fontStyle.fontWeight = "bold";
|
setting.fontStyle.fontWeight = "bold";
|
||||||
|
|
||||||
var startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "다시 시작", this.restartStage);
|
var startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "다시 시작", this.restartStage);
|
||||||
|
startButton.addShortcutText("Enter");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ var Start = {
|
|||||||
setting.fontStyle.fontWeight = "bold";
|
setting.fontStyle.fontWeight = "bold";
|
||||||
|
|
||||||
var startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "시작", this.startStage);
|
var startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "시작", this.startStage);
|
||||||
|
startButton.addShortcutText("Enter");
|
||||||
},
|
},
|
||||||
|
|
||||||
makeRankingButton: function() {
|
makeRankingButton: function() {
|
||||||
|
|||||||
Reference in new issue
Block a user