Constructor
new PlayGameIcon()
Constructs the PlayGameIcon, loads the play 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 event triggered by user interaction. |
- 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 PlayGameIcon.
If they are, and if the game is not started and the start screen is showing,
toggles the game state.
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 game toggle action if conditions are met.
Parameters:
| Name | Type | Description |
|---|---|---|
event |
MouseEvent | TouchEvent | The user interaction event. |
- Source:
toggleGame()
Toggles the game from the start screen state to the playing state,
initiating all necessary intervals and hiding the start screen.
- Source:
updatePosition()
Updates the position of the PlayGameIcon based on the current canvas size.
- Source: