Button
Button
is a class that extends the Clickable
class. It allows the management of buttons.
info
This class extends from Clickable
.
All getters, setters and methods from Clickable
are available here!
Constructor
prototype
constructor(area: Rectangle, options: ButtonOptions, disabled: boolean = false);
Properties
area
- Type:
Rectangle
- The clickable area.
- Type:
options
- Type:
ButtonOptions
- The button options.
- Type:
disabled
- Type:
boolean
- Default value:
false
- Whether the button is disabled.
- Type:
Example
const options = {
nineSlices: new Map([
[ClickableState.Released, new NineSlice(new Rectangle(0, 0, 100, 100), 10, 10, 10, 10)],
...
]),
}
const button = new Button(new Rectangle(0, 0, 100, 100), options);
Methods
update
prototype
update(deltaTime: number): void;
Updates the button.
Parameters
deltaTime
- Type:
number
- The time since the last update.
- Type:
Return
void
Example
button.update(deltaTime);
draw
prototype
draw(context: CanvasRenderingContext2D): void;
Draws the button.
Parameters
context
- Type:
CanvasRenderingContext2D
- The canvas rendering context.
- Type:
Return
void
Example
button.draw(context);