MessagePanel

Extends: BGE.UI.MenuList

A centered modal panel (heading, message, a column of buttons) for pause menus, win/game-over screens and similar: a BGE.UI.MenuList that centers itself on show().

show() builds the panel's children fresh and focuses the first button; hide() removes the panel, so its buttons aren't focusable while it's hidden. Pass 0 for the width or height to fit the content. Colors come from the theme (panelBackgroundColor, panelTitleColor, panelTextColor), unless backgroundRGBA is set.

Properties

  • buttonSpecs (Array.<BGE.UI.MessagePanelButton>) — The button specs given to the constructor, top to bottom.
  • buttonWidgets (Array.<BGE.UI.Button>) — The BGE.UI.Button widgets built from buttonSpecs, in the same order - only valid

Constructor

new MessagePanel( game: BGE.Game, panelWidth: float, panelHeight: float, buttons: Array.<BGE.UI.MessagePanelButton>, title?: string, message?: string, ): MessagePanel

Parameters

  • game (BGE.Game)
  • panelWidth (float) — 0 fits the content
  • panelHeight (float) — 0 fits the content
  • buttons (Array.<BGE.UI.MessagePanelButton>) — shown top to bottom
  • title (string, optional, default: "\"\"") — optional heading, drawn in the "heading" font
  • message (string, optional, default: "\"\"") — optional body text below the heading

Instance Methods

show( parent?: BGE.UI.UiContainer, withinWidth?: float, withinHeight?: float, ): void

Centers this panel within a withinWidth x withinHeight area (typically the UI canvas size), builds it, adds it to parent and focuses the first button. With no parent it's owned by the current scene (see MenuList.open()). Showing an open panel rebuilds it.

Parameters

  • parent (BGE.UI.UiContainer, optional, default: "invalid")
  • withinWidth (float, optional, default: 0) — 0 centers on the parent (the UI canvas for gameUi)
  • withinHeight (float, optional, default: 0)

Returns

  • void

hide(parent?: BGE.UI.UiContainer): void

Removes this panel (and its buttons) from its parent. show() again to reopen.

Parameters

  • parent (BGE.UI.UiContainer, optional, default: "invalid") — unused; kept for older callers

Returns

  • void