HomeButton.prototype = Object.create(RoundRectButton); HomeButton.constructor = HomeButton; function HomeButton(clickEvent) { var 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); }