• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

[Tạo 2D Platformer Game với Godot] Part 28: Adding interface sounds

AnonyViet by AnonyViet
January 26, 2023
in Tips
0

In this section, I will show you how to add sounds when clicking buttons on the interface, etc.

Join the channel Telegram of the AnonyViet 👉 Link 👈

Sound

Get the sound

To get the sound, I won’t need to give you the download link here, you just need to go to the Asset lib to find Kenney and it will come out.

[Tạo 2D Platformer Game với Godot]  Part 28: Adding interface sounds

You can choose one of the two.[Tạo 2D Platformer Game với Godot]  Part 28: Adding 15 . interface audio

Then click download to download it.

[Tạo 2D Platformer Game với Godot]  Part 28: Adding 16 . interface audio

Once the download is complete, click Install to install it.

[Tạo 2D Platformer Game với Godot]  Part 28: Adding 17 . interface audio

It will display an interface showing the address of that addon and then click Install

[Tạo 2D Platformer Game với Godot]  Part 28: Adding 18 . interface audio

Then a new folder is created named addons and it contains the sound that I just installed in it

[Tạo 2D Platformer Game với Godot]  Part 28: Adding 19 . interface audio

Regarding the audio files, it is also labeled with the name in front so you can know which one to use and which one to use.

Add to scene

After successful installation, I proceed to add it to the game.

[Tạo 2D Platformer Game với Godot]  Part 28: Adding 20 . interface audio

Get yourself an AudioStreamPlayer2D node node[Tạo 2D Platformer Game với Godot]  Part 28: Adding 21 . interface audio

Here I am adding to the Menu scene.

[Tạo 2D Platformer Game với Godot]  Part 28: Adding 22 . interface audio[Tạo 2D Platformer Game với Godot]  Part 28: Adding 23 . interface audio[Tạo 2D Platformer Game với Godot]  Part 28: Adding 24 . interface audio

Here I am doing Audio when I click the Start button so I will find the sound named click and drag it into the Stream of Audio Stream Player 2D.

After dragging is done, you can call it in code with the play() function.

extends Control
func _on_NutBatDau_pressed():
    $AudioStreamPlayer2D.play()
    yield(get_tree().create_timer(0,1),"timeout")
    get_tree().change_scene("res://Scences/Map/LevelMap.tscn")
    pass # Replace with function body.
func _on_NutThoatGame_pressed():
    get_tree().quit()
    pass # Replace with function body.

The line of code above, I added the line $AudioStreamPlayer2D.play() I will play the sound when I press the start button

yield(get_tree().create_timer(0,1),"timeout"): is that I create a timer with gin 0.1s, after 0.1s is over, it will run the change_scene() command. Here, I use this command because when I press just add the play() line and then change_scene it will not play the sound (depending on the device) so I will add the yield command so that after it plays the sound, then change scene.

You may not need to add yield() if the one you want to play the audio doesn’t need to change the scene.

[Tạo 2D Platformer Game với Godot]  Part 28: Adding 25 . interface audio

I will make one more in the PauseMenu scene.[Tạo 2D Platformer Game với Godot]  Part 28: Adding 26 . interface audio

You add sound.

Then in the function that shows the menu sound I have:

func _on_HienPauseMenu_pressed():
    
    get_node("AudioStreamPlayer2D").play()
    $PauseMenu.show()
    get_tree().paused = true
    pass # Replace with function body.

Then after you press and test it, you will see it has a click sound when clicked.

Summary

So in this part, I showed you how to add sound to the game.

The article achieved: 5/5 – (100 votes)

Tags: AddingGameGodotinterfacePartPlatformersoundstạovới
Previous Post

Lesson 15: Multiplication in Excel – Basic Excel

Next Post

How to create a Windows VPS 3h RAM 7Gb with Azure’s CloudGuard

AnonyViet

AnonyViet

Related Posts

How to view web access history in the anonymous mode (Incognito) of Chrome
Tips

How to view web access history in the anonymous mode (Incognito) of Chrome

August 22, 2025
How to graft the peach branch based on electric poles, family cycling, uncle
Tips

How to graft the peach branch based on electric poles, family cycling, uncle

August 21, 2025
Unlock checkpoint 72h often have photos already but hang nick
Tips

Unlock checkpoint 72h often have photos already but hang nick

August 19, 2025
GIF image creation tips with high quality snipping tool
Tips

GIF image creation tips with high quality snipping tool

August 19, 2025
How to unlock Facebook to download your latest photos
Tips

How to unlock Facebook to download your latest photos

August 18, 2025
Instructions on how to format text on the Windows 11 notepad
Tips

Instructions on how to format text on the Windows 11 notepad

August 16, 2025
Next Post
How to create a Windows VPS 3h RAM 7Gb with Azure’s CloudGuard

How to create a Windows VPS 3h RAM 7Gb with Azure's CloudGuard

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

How to view web access history in the anonymous mode (Incognito) of Chrome

How to view web access history in the anonymous mode (Incognito) of Chrome

August 22, 2025
How to automatically erase the web history after escaping to absolutely secure

How to automatically erase the web history after escaping to absolutely secure

August 22, 2025
Stainless steel flange price list at Asia Industry

Stainless steel flange price list at Asia Industry

August 21, 2025

Hướng Dẫn Đăng Nhập VN88

August 21, 2025
How to view web access history in the anonymous mode (Incognito) of Chrome

How to view web access history in the anonymous mode (Incognito) of Chrome

August 22, 2025
How to automatically erase the web history after escaping to absolutely secure

How to automatically erase the web history after escaping to absolutely secure

August 22, 2025
Stainless steel flange price list at Asia Industry

Stainless steel flange price list at Asia Industry

August 21, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

How to view web access history in the anonymous mode (Incognito) of Chrome

How to view web access history in the anonymous mode (Incognito) of Chrome

August 22, 2025
How to automatically erase the web history after escaping to absolutely secure

How to automatically erase the web history after escaping to absolutely secure

August 22, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí mm88 8XBET mm88 trang chủ new88

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply