Class: InstructionIcon

InstructionIcon()

Represents an instruction icon in the game, extending the DrawableObject class. When clicked or touched (if the game has not started), it navigates to "instruction.html".

Constructor

new InstructionIcon()

Initializes the InstructionIcon, loads its image, positions it, and sets up the event listeners.
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 instruction icon. If they are and the game has not started, navigates to "instruction.html".
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 and touchstart events. Calculates the coordinates and processes the navigation if conditions are met.
Parameters:
Name Type Description
event MouseEvent | TouchEvent The user interaction event.
Source:

onRelease(event)

Handles mouseup and touchend events, preventing default behavior.
Parameters:
Name Type Description
event MouseEvent | TouchEvent The user interaction event.
Source:

updatePosition()

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