|
@@ -35,13 +35,60 @@ audio file.
|
|
|
|
|
|
All audio is automatically imported with the ``Loop`` setting disabled.
|
|
|
If you want the music to loop seamlessly, click on the Stream file arrow,
|
|
|
-select ``Make Unique``, then click on the Stream file and check the ``Loop`` box.
|
|
|
+select ``Make Unique``, then click on the Stream file and check the ``Loop`` box.
|
|
|
|
|
|
To play the music, add ``$Music.play()`` in the ``new_game()``
|
|
|
function and ``$Music.stop()`` in the ``game_over()`` function.
|
|
|
|
|
|
Finally, add ``$DeathSound.play()`` in the ``game_over()`` function.
|
|
|
|
|
|
+.. tabs::
|
|
|
+ .. code-tab:: gdscript GDScript
|
|
|
+
|
|
|
+ func game_over():
|
|
|
+ ...
|
|
|
+ $Music.stop()
|
|
|
+ $DeathSound.play()
|
|
|
+
|
|
|
+ func new_game():
|
|
|
+ ...
|
|
|
+ $Music.play()
|
|
|
+
|
|
|
+ .. code-tab:: csharp
|
|
|
+
|
|
|
+ public void GameOver()
|
|
|
+ {
|
|
|
+ ...
|
|
|
+ GetNode<AudioStreamPlayer>("Music").Stop();
|
|
|
+ GetNode<AudioStreamPlayer>("DeathSound").Play();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void NewGame()
|
|
|
+ {
|
|
|
+ ...
|
|
|
+ GetNode<AudioStreamPlayer>("Music").Play();
|
|
|
+ }
|
|
|
+
|
|
|
+ .. code-tab:: cpp
|
|
|
+
|
|
|
+ void Main::_ready() {
|
|
|
+ ...
|
|
|
+ _music = get_node<godot::AudioStreamPlayer>("Music");
|
|
|
+ _death_sound = get_node<godot::AudioStreamPlayer>("DeathSound");
|
|
|
+ }
|
|
|
+
|
|
|
+ void Main::game_over() {
|
|
|
+ ...
|
|
|
+ _music->stop();
|
|
|
+ _death_sound->play();
|
|
|
+ }
|
|
|
+
|
|
|
+ void Main::new_game() {
|
|
|
+ ...
|
|
|
+ _music->play();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
Keyboard shortcut
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|