The Button component creates an interactive button that can be clicked or pressed.
It supports rectangular or circular shapes and can be configured with dimensions, position offset, touch input, and click/press event handlers.

const button = new Button({
shape: ButtonShape.Rectangle,
width: 100,
height: 50,
offset: new Vector2(0, 0),
touchEnabled: true,
onClick: () => console.log("Button clicked!"),
onPressed: () => console.log("Button pressed!")
});

Constructors

Properties

height: number = 0

Height in pixels. Only for rectangle shaped buttons

mouseOver: boolean = false

TRUE if mouse cursor is over the button

offset: Vector2 = ...

X-axis and Y-axis offset

onClick: (() => void)

Function executed when the button's click

onPressed: (() => void)

Function executed when the button is pressed

pressed: boolean = false

TRUE if it's pressed

radius: number = 0

Radius in pixels. Only for circumference shaped buttons

The shape of the button

touchEnabled: boolean = true

Enables interaction with touch screens

width: number = 0

Width in pixels. Only for rectangle shaped buttons