BackButton.prototype = Object.create(RoundRectButton); BackButton.constructor = BackButton; function BackButton(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( 0xaa6666, 0x884444, 0x884444, 0x333333 ); setting.setButtonColor( 0xffdddd, 0xddaaaa, 0xddaaaa, 0x666666 ); setting.setTextColor( "#a66", "#844", "#844", "#333" ); var backButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "<", clickEvent); backButton.addShortcutText("ESC"); } BackButton.prototype.startState = function(stateName) { var game = this.backButton.parent.game; game.state.start(stateName); }