51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
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.strokeWidthPx = 3;
|
|
setting.setStrokeColor(
|
|
0x444488,
|
|
0x6666aa,
|
|
0x6666aa,
|
|
0x333333
|
|
);
|
|
setting.setButtonColor(
|
|
0xaaaadd,
|
|
0xddddff,
|
|
0xddddff,
|
|
0x666666
|
|
);
|
|
setting.setTextColor(
|
|
"#844",
|
|
"#a66",
|
|
"#a66",
|
|
"#333"
|
|
);
|
|
|
|
let button = new RoundRectButton(
|
|
setting, RoundRectButton.NONE_ICON, RoundRectButton.NONE_BUTTON_TEXT,
|
|
() => 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();
|
|
}
|
|
}
|
|
|
|
} |