Constructor
new Jump()
Initializes the Jump 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 Jump button.
If they are, it sets the 'UP' 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.
Sets the 'UP' key in the keyboard object to false, ending the jump 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 jump 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 Jump button based on the canvas size.
- Source: