summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2020-02-27 22:49:46 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2020-02-27 22:52:21 +0100
commita6fd6b78dd267d21ea30cc644d8aad10bc0f66ce (patch)
tree3d5dcb70d6f29f4277d3fd9e60d8dce124aa0c8a
parente66d519286693a03bf59eaba0a5f29c1c9b15d64 (diff)
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.
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml8
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index cf76c09294..5e69bfd99b 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -596,7 +596,13 @@
<argument index="0" name="nrg" type="float">
</argument>
<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>
</method>
<method name="load">