mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2024-11-14 21:15:58 +00:00
Added AudioBus. SFX Vol slider now works
This commit is contained in:
parent
9929aab354
commit
388fcb9483
@ -7,3 +7,9 @@ bus/1/mute = false
|
||||
bus/1/bypass_fx = false
|
||||
bus/1/volume_db = 0.0
|
||||
bus/1/send = "Master"
|
||||
bus/2/name = "SFX"
|
||||
bus/2/solo = false
|
||||
bus/2/mute = false
|
||||
bus/2/bypass_fx = false
|
||||
bus/2/volume_db = 0.0
|
||||
bus/2/send = "Master"
|
||||
|
@ -17,8 +17,9 @@ config/icon="res://icon.png"
|
||||
[autoload]
|
||||
|
||||
MessageBus="*res://script/game/Message Bus.gd"
|
||||
AudioBus="*res://script/game/Audio Bus.gd"
|
||||
OptionsController="*res://script/options/OptionsController.gd"
|
||||
AudioController="*res://scenes/BackgroundMusic.tscn"
|
||||
AudioController="*res://scenes/AudioController.tscn"
|
||||
|
||||
[display]
|
||||
|
||||
|
22
godot_ship/scenes/AudioController.tscn
Normal file
22
godot_ship/scenes/AudioController.tscn
Normal file
@ -0,0 +1,22 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://assets/audio/BGM - Captain Scurvy.ogg" type="AudioStream" id=1]
|
||||
[ext_resource path="res://script/audio controller/AudioController.gd" type="Script" id=2]
|
||||
[ext_resource path="res://assets/audio/ButtonSFX.ogg" type="AudioStream" id=3]
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="BGM" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 1 )
|
||||
autoplay = true
|
||||
bus = "BGM"
|
||||
|
||||
[node name="buttonSFX" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 3 )
|
||||
bus = "SFX"
|
@ -1,15 +0,0 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://assets/audio/BGM - Captain Scurvy.ogg" type="AudioStream" id=1]
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="BGM" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 1 )
|
||||
autoplay = true
|
||||
bus = "BGM"
|
@ -1,8 +1,7 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://script/options/Option-Background.png" type="Texture" id=1]
|
||||
[ext_resource path="res://script/options/Options.gd" type="Script" id=2]
|
||||
[ext_resource path="res://assets/audio/ButtonSFX.ogg" type="AudioStream" id=3]
|
||||
|
||||
[node name="Options" type="Control"]
|
||||
anchor_right = 1.0
|
||||
@ -68,7 +67,7 @@ focus_neighbour_top = NodePath("../../../Back")
|
||||
focus_neighbour_bottom = NodePath("../../Volume Setting/Volume Slider")
|
||||
focus_next = NodePath("../../Volume Setting/Volume Slider")
|
||||
focus_previous = NodePath("../../../Back")
|
||||
min_value = -30.0
|
||||
min_value = -25.0
|
||||
max_value = 0.0
|
||||
tick_count = 11
|
||||
__meta__ = {
|
||||
@ -156,9 +155,6 @@ __meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ButtonSFX" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 3 )
|
||||
|
||||
[connection signal="value_changed" from="Sliders/SFX Setting/SFX Slider" to="." method="_on_SFX_Slider_value_changed"]
|
||||
[connection signal="value_changed" from="Sliders/Volume Setting/Volume Slider" to="." method="_on_Volume_Slider_value_changed"]
|
||||
[connection signal="pressed" from="Buttons/Light" to="." method="_on_Light_pressed"]
|
||||
|
@ -1,8 +1,7 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://script/title screen/Title-Screen-Background.png" type="Texture" id=1]
|
||||
[ext_resource path="res://script/title screen/Title Screen.gd" type="Script" id=2]
|
||||
[ext_resource path="res://assets/audio/ButtonSFX.ogg" type="AudioStream" id=3]
|
||||
|
||||
[node name="Title Node" type="Control"]
|
||||
anchor_right = 1.0
|
||||
@ -16,9 +15,6 @@ __meta__ = {
|
||||
position = Vector2( 320, 180 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="ButtonSFX" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 3 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
|
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")
|
||||
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user