UISystemPlugin

LittleJS User Interface Plugin

  • Nested Menus
  • Text
  • Buttons
  • Checkboxes
  • Images

Members

(static) uiContext :CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D

Context to render UI elements to

Type:
  • CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D

(static) uiDefaultButtonColor :Color

Default button color for UI elements

Type:

(static) uiDefaultColor :Color

Default fill color for UI elements

Type:

(static) uiDefaultFont :string

Default font for UI elements

Type:
  • string

(static) uiDefaultHoverColor :Color

Default hover color for UI elements

Type:

(static) uiDefaultLineColor :Color

Default outline color for UI elements

Type:

(static) uiDefaultLineWidth :number

Default line width for UI elements

Type:
  • number

(static) uiDefaultTextColor :Color

Default text color for UI elements

Type:

(static) uiObjects :Array.<UIObject>

List of all UI elements

Type:

Methods

(static) drawUILine(posA, posB, lineWidthopt, lineColoropt)

Draw a line to the UI context

Parameters:
NameTypeAttributesDefaultDescription
posAVector2
posBVector2
lineWidthnumber<optional>
uiDefaultLineWidth
lineColorColor<optional>
uiDefaultLineColor

(static) drawUIRect(pos, size, coloropt, lineWidthopt, lineColoropt)

Draw a rectangle to the UI context

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2
colorColor<optional>
uiDefaultColor
lineWidthnumber<optional>
uiDefaultLineWidth
lineColorColor<optional>
uiDefaultLineColor

(static) drawUIText(text, pos, size, coloropt, lineWidthopt, lineColoropt, alignopt, fontopt)

Draw text to the UI context

Parameters:
NameTypeAttributesDefaultDescription
textstring
posVector2
sizeVector2
colorColor<optional>
uiDefaultColor
lineWidthnumber<optional>
uiDefaultLineWidth
lineColorColor<optional>
uiDefaultLineColor
alignstring<optional>
center
fontstring<optional>
uiDefaultFont

(static) drawUITile(pos, size, tileInfo, coloropt, angleopt, mirroropt)

Draw a tile to the UI context

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2
tileInfoTileInfo
colorColor<optional>
uiDefaultColor
anglenumber<optional>
0
mirrorboolean<optional>
false

(static) initUISystem(contextopt)

Set up the UI system, typically called in gameInit

Parameters:
NameTypeAttributesDefaultDescription
contextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2D<optional>
overlayContext