ControllerQrWidget

Extends: BGE.UI.UiWidget

A QR code for the phone/browser controller page, with a caption and the URL under it. The URL defaults to game.getControllerConnectionInfo() (call game.enableControllerInput() first). It's encoded once; setUrl() changes it.

The code is centered in the widget's width with the text below; height is worked out from the content. qrSize is rounded down to whole pixels per module, or the modules show gaps.

Properties

  • caption (string)
  • showUrl (boolean)
  • textColor (integer)
  • fontName (string) — Font key ("body", falling back to "default").
  • backgroundRGBA (integer) — Fill drawn behind everything, 0 for none.
  • contentPadding (float)
  • gap (float) — Space between the code and the text.

Example

CODE
qr = new BGE.UI.ControllerQrWidget(game)
qr.customPosition = true
qr.customX = 100
qr.customY = 80
scene.addUi(qr)

Constructor

new ControllerQrWidget( game: BGE.Game, url?: string, qrSize?: float, ): ControllerQrWidget

Parameters

  • game (BGE.Game)
  • url (string, optional, default: "\"\"") — "" uses game.getControllerConnectionInfo()
  • qrSize (float, optional, default: "240.0") — pixels across the code

Instance Methods

setUrl(url: string): void

Encodes a new URL.

Parameters

  • url (string)

Returns

  • void

getUrl(): string

The encoded URL ("" if none).

Returns

  • string

setQrSize(qrSize: float): void

Sets how many pixels across the code should be (rounded down to whole pixels per module).

Parameters

  • qrSize (float)

Returns

  • void

getQrSize(): float

The code's drawn size in pixels.

Returns

  • float

setWidth(width: float): void

Fixes the widget's width (the text wraps to it); 0 fits it to the code.

Parameters

  • width (float)

Returns

  • void

draw(parent?: UiWidget): void

Parameters

  • parent (UiWidget, optional, default: "invalid")

Returns

  • void

layout(): void

Sizes the widget to its content. Runs by itself when the caption, showUrl, contentPadding or gap change; call it to read the new height before the next draw.

Returns

  • void