Constructor
new SoundsMuteIcon()
Constructs a new SoundsMuteIcon, loads the correct icon based on the stored mute status in localStorage,
sets up its position and dimensions, and attaches the necessary event listeners.
- Source:
Members
isMuted :boolean
Indicates whether the sound effects are 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 sound mute icon.
If they are, toggles the sound mute state.
Parameters:
| Name | Type | Description |
|---|---|---|
mouseX |
number | The x coordinate relative to the canvas. |
mouseY |
number | The y coordinate relative to the canvas. |
- Source:
muteSound()
Applies the mute setting to all game sound effects managed by the world's audio manager.
- Source:
onClick(event)
Handles click and touch events on the icon.
Calculates the coordinates and processes the toggle sound action if conditions are met.
Parameters:
| Name | Type | Description |
|---|---|---|
event |
MouseEvent | TouchEvent | The user interaction event. |
- Source:
toggleSound()
Toggles the sound mute state, updates the icon image, stores the new status in localStorage,
and applies the setting to all game sound effects.
- Source:
updatePosition()
Updates the position of the sound mute icon based on the current canvas size.
- Source: