Add: home button
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
HomeButton.prototype = Object.create(RoundRectButton);
|
||||
HomeButton.constructor = HomeButton;
|
||||
|
||||
function HomeButton(clickEvent) {
|
||||
let setting = new RoundRectButtonSetting(30, 30, 50, 50);
|
||||
setting.fontStyle.boundsAlignH = "center"; // left, center. right
|
||||
setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom
|
||||
setting.strokeWidthPx = 3;
|
||||
setting.setStrokeColor(
|
||||
0xaa6022,
|
||||
0x994422,
|
||||
0x994422,
|
||||
0x333333
|
||||
);
|
||||
setting.setButtonColor(
|
||||
0x994c00,
|
||||
0x772c00,
|
||||
0x772c00,
|
||||
0x666666
|
||||
);
|
||||
setting.setTextColor(
|
||||
"#fec",
|
||||
"#dca",
|
||||
"#dca",
|
||||
"#333"
|
||||
);
|
||||
|
||||
var homeButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "", clickEvent);
|
||||
var icon_fullscreen = game.add.sprite(0, 0, "icon_home");
|
||||
icon_fullscreen.width = 26;
|
||||
icon_fullscreen.height = 26;
|
||||
homeButton.setIcon(icon_fullscreen);
|
||||
homeButton.buttonIcon.y -= 5;
|
||||
|
||||
homeButton.addShortcutText("ESC");
|
||||
}
|
||||
|
||||
HomeButton.prototype.startState = function(stateName) {
|
||||
var game = this.homeButton.parent.game;
|
||||
game.state.start(stateName);
|
||||
}
|
||||
@@ -15,6 +15,10 @@ ScreenTopUI.prototype.makeBackButton = function(eventHandler) {
|
||||
this.backButton = new BackButton(eventHandler);
|
||||
}
|
||||
|
||||
ScreenTopUI.prototype.makeHomeButton = function(eventHandler) {
|
||||
this.homeButton = new HomeButton(eventHandler);
|
||||
}
|
||||
|
||||
ScreenTopUI.prototype.makeFullScreenButton = function() {
|
||||
// this.fullscreenButton = new FullscreenButton();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user