mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2025-02-04 12:28:35 +00:00
Added AudioBus. SFX Vol slider now works
This commit is contained in:
17
godot_ship/script/audio controller/AudioController.gd
Normal file
17
godot_ship/script/audio controller/AudioController.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
extends Control
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
var _errno = 0
|
||||
_errno += AudioBus.connect("button_clicked", self, "_button_clicked")
|
||||
|
||||
func _button_clicked():
|
||||
$buttonSFX.play()
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
8
godot_ship/script/game/Audio Bus.gd
Normal file
8
godot_ship/script/game/Audio Bus.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# Ignore "unused signal" warnings in this class
|
||||
# warning-ignore-all:unused_signal
|
||||
|
||||
# Ask for a scene change
|
||||
signal button_clicked
|
||||
@@ -13,11 +13,12 @@ func _ready():
|
||||
music_slider.value = OptionsController.get_mus_volume()
|
||||
|
||||
func _on_Button_pressed():
|
||||
$ButtonSFX.play()
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
queue_free()
|
||||
# MessageBus.emit_signal("change_scene", "Title")
|
||||
#MessageBus.emit_signal("change_scene", "Title")
|
||||
|
||||
func _on_SFX_Slider_value_changed(value):
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
OptionsController.set_sfx_vol(value)
|
||||
OptionsController.save_options()
|
||||
|
||||
@@ -26,11 +27,11 @@ func _on_Volume_Slider_value_changed(value):
|
||||
OptionsController.save_options()
|
||||
|
||||
func _on_Light_pressed():
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
OptionsController.set_theme("light")
|
||||
OptionsController.save_options()
|
||||
$ButtonSFX.play()
|
||||
|
||||
func _on_Dark_pressed():
|
||||
AudioBus.emit_signal("button_clicked")
|
||||
OptionsController.set_theme("dark")
|
||||
OptionsController.save_options()
|
||||
$ButtonSFX.play()
|
||||
|
||||
@@ -28,6 +28,7 @@ func set_mus_vol(volume):
|
||||
emit_signal("change_mus_volume", mus_vol)
|
||||
func set_sfx_vol(volume):
|
||||
sfx_vol = volume
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SFX"), sfx_vol)
|
||||
emit_signal("change_sfx_volume", sfx_vol)
|
||||
|
||||
#Option Save File
|
||||
@@ -45,6 +46,7 @@ func load_options():
|
||||
sfx_vol = f.get_var()
|
||||
f.close()
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("BGM"), mus_vol)
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SFX"), sfx_vol)
|
||||
|
||||
# Getters
|
||||
func get_theme():
|
||||
|
||||
@@ -5,21 +5,17 @@ func _ready():
|
||||
$VBoxContainer/Singleplayer.grab_focus()
|
||||
|
||||
func _on_Singleplayer_pressed():
|
||||
$ButtonSFX.play()
|
||||
MessageBus.emit_signal("change_scene", "Singleplayer")
|
||||
queue_free()
|
||||
|
||||
func _on_Multiplayer_pressed():
|
||||
$ButtonSFX.play()
|
||||
MessageBus.emit_signal("change_scene", "Multiplayer")
|
||||
queue_free()
|
||||
|
||||
func _on_Options_pressed():
|
||||
$ButtonSFX.play()
|
||||
MessageBus.emit_signal("change_scene", "Options")
|
||||
queue_free()
|
||||
|
||||
func _on_Quit_pressed():
|
||||
$ButtonSFX.play()
|
||||
MessageBus.emit_signal("quit")
|
||||
queue_free()
|
||||
|
||||
Reference in New Issue
Block a user