Class: MusicsMuteIcon

MusicsMuteIcon()

Represents an icon that toggles the background music between mute and unmute. Extends the DrawableObject class.

Constructor

new MusicsMuteIcon()

Constructs a new MusicsMuteIcon, loading the correct icon based on the stored mute status in localStorage. Also attaches click and touch event listeners.
Source:

Members

isMuted :boolean

Indicates whether the music is currently muted.
Type:
  • boolean
Source:

mute :string

The image path for the muted icon.
Type:
  • string
Source:

nonMute :string

The image path for the non-muted icon.
Type:
  • string
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 mute icon. If they are, toggles the background sound.
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 the click or touch event. Calculates the coordinates and processes the toggle sound action if conditions are met.
Parameters:
Name Type Description
event MouseEvent | TouchEvent The event triggered by user interaction.
Source:

toggleSound()

Toggles the background sound between mute and unmute. Updates the icon image, stores the new mute status in localStorage, and pauses/plays the background sound accordingly.
Source:

updatePosition()

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