feat: Allow volume control of Music & Sound with property #1311
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Issue Link: #1310
Here's an implementation that allow custom Volume configuration of all Sounds & Musics. I've placed the "Master / Global" volume property of the AudioType inside them. This felt pretty natural since the "expert" (GRAPS) of that information is the AudioType itself. This also mean that we could really easily add a new AudioType without much efforts and that new type would automatically mix itself against the Global and the current Audio.
@AlmasB NOTE: I took the initiative to revert the changes made in #1187. Granting access to the internal audio is causing a bug related to volume adjustments in the settings. Whenever a player was adjusting his Global volume, all custom changes made on the audio (getAudio()) was automatically reverted. With this implementation, the conjunction of the 2 values are always kept (via the mix() method)
Example:
Note that changing the Global Music volume will also automatically impact all Music:
I've tested it on my own game and I needed it!
I hope you like it! :)