Add a practical example for @GDScript.linear2db()
One of its most common applications in games is for volume sliders. See https://www.dr-lex.be/info-stuff/volumecontrols.html for more information.
This commit is contained in:
parent
e66d519286
commit
a6fd6b78dd
1 changed files with 7 additions and 1 deletions
|
@ -596,7 +596,13 @@
|
||||||
<argument index="0" name="nrg" type="float">
|
<argument index="0" name="nrg" type="float">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Converts from linear energy to decibels (audio).
|
Converts from linear energy to decibels (audio). This can be used to implement volume sliders that behave as expected (since volume isn't linear). Example:
|
||||||
|
[codeblock]
|
||||||
|
# "Slider" refers to a node that inherits Range such as HSlider or VSlider.
|
||||||
|
# Its range must be configured to go from 0 to 1.
|
||||||
|
# Change the bus name if you'd like to change the volume of a specific bus only.
|
||||||
|
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), linear2db($Slider.value))
|
||||||
|
[/codeblock]
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="load">
|
<method name="load">
|
||||||
|
|
Loading…
Reference in a new issue