Class: MoveRaight

MoveRaight()

Represents a "move right" button in the game, extending the DrawableObject class. When touched, it triggers a move right action by setting the 'RIGHT' key in the keyboard object to true.

Constructor

new MoveRaight()

Initializes the MoveRaight 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 MoveRaight button. If they are, it sets the 'RIGHT' 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 'RIGHT' key in the keyboard object to false, stopping the move right 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 right 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 MoveRaight button based on the canvas size.
Source: