Class: HomeIcon

HomeIcon()

Represents a home icon button in the game, extending the DrawableObject class. When clicked or touched, it stops the current game and resets it to the start screen.

Constructor

new HomeIcon()

Initializes the HomeIcon, loads its image, sets event listeners for click and touch, and binds a resize event to update its position.
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 home icon button. If the click/touch is within bounds and the start screen is not currently shown, it stops and resets the game.
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 both click and touch events to determine if the home icon was pressed. It calculates the mouse or touch coordinates and then checks if the click occurred within the button's bounds.
Parameters:
Name Type Description
event MouseEvent | TouchEvent The event triggered by user interaction.
Source:

updatePosition()

Updates the position of the home icon based on the current canvas size.
Source: