Constructor
new MoveLeft()
Initializes the MoveLeft 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 MoveLeft button.
If they are, it sets the 'LEFT' 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 'LEFT' key in the keyboard object to false, stopping the move left 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 triggers the move left action if the touch is within the button's bounds.
Parameters:
| Name | Type | Description |
|---|---|---|
event |
TouchEvent | The touch event triggered by user interaction. |
- Source:
updatePosition()
Updates the position of the MoveLeft button based on the canvas size.
- Source: