Clickable
The Clickable
class provide an area with features like a button.
Constructor
prototype
constructor(area: Rectangle, disabled: boolean = false)
Properties
area
- Type:
Rectangle
- The clickable area.
- Type:
disabled
- Type:
boolean
- Default value:
false
- Whether the clickable is disabled.
- Type:
Getters
area
- Type:
Rectangle
The area of the clickable (relative to the canvas).
isDisabled
- Type:
boolean
Whether the clickable is disabled.
isClicked
- Type:
boolean
Whether the clickable is clicked.
isPressed
- Type:
boolean
Whether the clickable is pressed.
isHovered
- Type:
boolean
Whether the clickable is hovered.
isReleased
- Type:
boolean
Whether the clickable is released.
Methods
disable
prototype
disable(disabled: boolean = true): void
Disables the clickable.
Parameters
disabled
- Type:
boolean
- Default value:
true
- Whether the clickable is disabled.
- Type:
Return
void
Example
const clickable = new Clickable(new Rectangle(0, 0, 100, 100));
clickable.disable();
enable
prototype
enable(enabled: boolean = true): void
Enables the clickable.
Parameters
enabled
- Type:
boolean
- Default value:
true
- Whether the clickable is enabled.
- Type:
Return
void
Example
const clickable = new Clickable(new Rectangle(0, 0, 100, 100));
clickable.enable();
update
prototype
update(deltaTime: number): void
Updates the clickable state.
Parameters
deltaTime
- Type:
number
- The time since the last update.
- Type:
Return
void
Example
const clickable = new Clickable(new Rectangle(0, 0, 100, 100));
//...
clickable.update(deltaTime);