Constructor
new Buy()
Initializes the Buy button, loads the image, sets its dimensions and position,
and attaches touch event listeners.
- Source:
Methods
getTouchCoordinates(event) → {Object}
Calculates the touch coordinates relative to the canvas.
Parameters:
| Name | Type | Description |
|---|---|---|
event |
TouchEvent | The touch event triggered by user interaction. |
- Source:
Returns:
An object containing the calculated x and y coordinates.
- Type
- Object
handleTouchStartCoordinates(touchX, touchY)
Checks if the provided touch coordinates are within the bounds of the Buy button.
If they are, it sets the 'DOWN' key in the keyboard object to true.
Parameters:
| Name | Type | Description |
|---|---|---|
touchX |
number | The x coordinate relative to the canvas. |
touchY |
number | The y coordinate relative to the canvas. |
- Source:
onTouchEnd(event)
Handler for the touchend event.
Resets the 'DOWN' key in the keyboard object to false, ending the action.
Parameters:
| Name | Type | Description |
|---|---|---|
event |
TouchEvent | The touch event triggered by user interaction. |
- Source:
onTouchStart(event)
Handler for the touchstart event.
Calculates the touch coordinates and processes the touch start action.
Parameters:
| Name | Type | Description |
|---|---|---|
event |
TouchEvent | The touch event triggered by user interaction. |
- Source:
updatePosition()
Updates the position of the Buy button based on the canvas size.
- Source: