Add: RoundRectButton icon
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
class FullscreenButton {
|
||||
|
||||
constructor(game) {
|
||||
this.game = game;
|
||||
|
||||
this.game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT;
|
||||
|
||||
let setting = new RoundRectButtonSetting(50, 50);
|
||||
setting.fontStyle.boundsAlignH = "center"; // left, center. right
|
||||
setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom
|
||||
setting.setStrokeColor(
|
||||
0x884444,
|
||||
0xaa6666,
|
||||
0xaa6666,
|
||||
0x333333
|
||||
);
|
||||
setting.setButtonColor(
|
||||
0xddaaaa,
|
||||
0xffdddd,
|
||||
0xffdddd,
|
||||
0x666666
|
||||
);
|
||||
setting.setTextColor(
|
||||
"#844",
|
||||
"#a66",
|
||||
"#a66",
|
||||
"#333"
|
||||
);
|
||||
|
||||
let button = new RoundRectButton(setting, "", () => this.clickEvent());
|
||||
button.move(this.game.world.width - 30, 30);
|
||||
|
||||
let icon_fullscreen = game.add.sprite(0, 0, 'icon_fullscreen');
|
||||
icon_fullscreen.width = 20;
|
||||
icon_fullscreen.height = 20;
|
||||
button.setIcon(icon_fullscreen);
|
||||
}
|
||||
|
||||
clickEvent() {
|
||||
if(this.game.scale.isFullScreen) {
|
||||
this.game.scale.stopFullScreen();
|
||||
} else {
|
||||
this.game.scale.startFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -146,29 +146,50 @@ class RoundRectButton {
|
||||
return btnText;
|
||||
}
|
||||
|
||||
setIcon(icon) {
|
||||
this.buttonIcon = this.button.addChild(icon);
|
||||
this.buttonIcon.x = this.button.width / 2;
|
||||
this.buttonIcon.y = this.button.height / 2;
|
||||
this.buttonIcon.anchor.setTo(0.5, 0.5);
|
||||
|
||||
this.mouseOut();
|
||||
}
|
||||
|
||||
|
||||
mouseOut() {
|
||||
this.text.fill = this.setting.textColors.out;
|
||||
this.buttonStroke.tint = this.setting.strokeColors.out;
|
||||
this.button.tint = this.setting.buttonColors.out;
|
||||
if(typeof this.buttonIcon !== "undefined") {
|
||||
this.buttonIcon.tint = this.setting.strokeColors.out;
|
||||
}
|
||||
}
|
||||
|
||||
mouseOver() {
|
||||
this.text.fill = this.setting.textColors.over;
|
||||
this.buttonStroke.tint = this.setting.strokeColors.over;
|
||||
this.button.tint = this.setting.buttonColors.over;
|
||||
if(typeof this.buttonIcon !== "undefined") {
|
||||
this.buttonIcon.tint = this.setting.strokeColors.over;
|
||||
}
|
||||
}
|
||||
|
||||
mouseDown() {
|
||||
this.text.fill = this.setting.textColors.down;
|
||||
this.buttonStroke.tint = this.setting.strokeColors.down;
|
||||
this.button.tint = this.setting.buttonColors.down;
|
||||
if(typeof this.buttonIcon !== "undefined") {
|
||||
this.buttonIcon.tint = this.setting.strokeColors.down;
|
||||
}
|
||||
}
|
||||
|
||||
buttonDisabled() {
|
||||
this.text.fill = this.setting.textColors.disabled;
|
||||
this.buttonStroke.tint = this.setting.strokeColors.disabled;
|
||||
this.button.tint = this.setting.buttonColors.disabled;
|
||||
if(typeof this.buttonIcon !== "undefined") {
|
||||
this.buttonIcon.tint = this.setting.strokeColors.disabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user