Constructor
new RestartGameIcon()
Constructs the RestartGameIcon, loads the restart image, sets up its position,
and attaches event listeners for clicks, touches, and window resizing.
- Source:
Methods
getMouseCoordinates(event) → {Object}
Calculates the mouse or touch coordinates relative to the canvas.
Parameters:
| Name | Type | Description |
|---|---|---|
event |
MouseEvent | TouchEvent | The user interaction event. |
- Source:
Returns:
An object containing the calculated x and y coordinates.
- Type
- Object
handleClick(mouseX, mouseY)
Checks if the provided coordinates are within the bounds of the RestartGameIcon.
If they are, and if either the boss is dead or the character's energy is depleted (while the game is started),
the game is restarted.
Parameters:
| Name | Type | Description |
|---|---|---|
mouseX |
number | The x coordinate relative to the canvas. |
mouseY |
number | The y coordinate relative to the canvas. |
- Source:
onClick(event)
Handles click or touch events.
Calculates the coordinates and processes the restart action if conditions are met.
Parameters:
| Name | Type | Description |
|---|---|---|
event |
MouseEvent | TouchEvent | The user interaction event. |
- Source:
updatePosition()
Updates the position of the RestartGameIcon based on the current canvas size.
- Source: