How to add sound?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By NowakSotto
:warning: Old Version Published before Godot 3 was released.

Hey guys, how do i add a sound into the tittle screen?

:bust_in_silhouette: Reply From: Freeman

If by title screen you mean the boot splash screen, then it’s not possible afaik.
If you mean the main scene - first scene that starts after the boot splash and for sure can imitate the title screen or game intro etc. - you have to add sampleplayer/streamplayer/etc. node to the scene, import some audio samples (if it’s longer music, you would probably want to stream it from filesystem) that you want to play (wav or ogg) and start playing from code. Sample playing code may looks for example like this:

get_node("sampleplayer").play("audiosample")

Thanks :).

And yes i mean the main scene.

in “audiosample” i need put the extension of the file too ?

NowakSotto | 2017-05-22 23:13

No, just the name that you used in the import.
If you are not sure how some simple things work in GDScript , it’s always good to open one of the example/demo projects (if you need sound check the one that uses sounds etc.) to check how the real code looks there. It’s always the fastest way to learn, at least for me :wink:

Freeman | 2017-05-23 00:18

oh thanks for remembering me about the exemples i really forget this

NowakSotto | 2017-05-23 00:42

Let me share just one more tip with you then. It was really an ice breaker when I could not find the answers on how something should work.
You go to github.com where Godot code and many other godot projects are and you use github’s search. For example, when you want to see examples of how to use SamplePlayer, you search for: SamplePlayer language:GDScript

Github will let you search within: Repositories, Code, Commits, Issues, Wikis and Users. You of course click on Code in the upper search summary menu… and voila, you see all the places in all projects written in GDScript that are on Github, that use SamplePlayer in their code. You may even download each project and run it in Godot to see how the code works.

Freeman | 2017-05-23 01:11

Really thanks again :).

Go start search there before asking here now

NowakSotto | 2017-05-23 14:12