-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from ligen131/feat-20240917-sound-manager
feat(sound_manager): 添加 Sound Manager 类
- Loading branch information
Showing
11 changed files
with
106 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[gd_resource type="AudioBusLayout" format=3 uid="uid://cvlcglbd4fsie"] | ||
|
||
[resource] | ||
bus/1/name = &"bgm" | ||
bus/1/solo = false | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 22 additions & 3 deletions
25
levels/chapter_menu/level_menu/level_button/level_button.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,38 @@ | ||
[gd_scene load_steps=4 format=3 uid="uid://bepyyenjtc0p3"] | ||
[gd_scene load_steps=8 format=3 uid="uid://bepyyenjtc0p3"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://drl1xe103umpi" path="res://objects/styled_button/styled_button.tscn" id="1_4bgxw"] | ||
[ext_resource type="Script" path="res://levels/chapter_menu/level_menu/level_button/level_button.gd" id="1_wwqfn"] | ||
[ext_resource type="PackedScene" uid="uid://cvx7wowcbfo0r" path="res://objects/word/word.tscn" id="3_js2i2"] | ||
[ext_resource type="Shader" path="res://objects/word/word.gdshader" id="4_6ctfu"] | ||
|
||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_c4861"] | ||
resource_local_to_scene = true | ||
shader = ExtResource("4_6ctfu") | ||
shader_parameter/color = null | ||
|
||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_a2kcy"] | ||
resource_local_to_scene = true | ||
shader = ExtResource("4_6ctfu") | ||
shader_parameter/color = null | ||
|
||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_y3jd6"] | ||
resource_local_to_scene = true | ||
shader = ExtResource("4_6ctfu") | ||
shader_parameter/color = null | ||
|
||
[node name="LevelButton" instance=ExtResource("1_4bgxw")] | ||
script = ExtResource("1_wwqfn") | ||
|
||
[node name="Word" parent="." index="0" instance=ExtResource("3_js2i2")] | ||
material = SubResource("ShaderMaterial_c4861") | ||
position = Vector2(17, 17) | ||
|
||
[node name="Word1" parent="." index="2" instance=ExtResource("3_js2i2")] | ||
[node name="Word1" parent="." index="1" instance=ExtResource("3_js2i2")] | ||
visible = false | ||
material = SubResource("ShaderMaterial_a2kcy") | ||
position = Vector2(11, 17) | ||
|
||
[node name="Word2" parent="." index="3" instance=ExtResource("3_js2i2")] | ||
[node name="Word2" parent="." index="2" instance=ExtResource("3_js2i2")] | ||
visible = false | ||
material = SubResource("ShaderMaterial_y3jd6") | ||
position = Vector2(23, 17) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
extends Button | ||
class_name StyledButton extends Button | ||
|
||
class_name StyledButton | ||
@export var sfx_button_down : AudioStream | ||
|
||
|
||
func _on_pressed(): | ||
$SFXButtonDown.play() | ||
SoundManager.play_sfx(self.sfx_button_down) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
extends Node | ||
|
||
var base_sfx_db := 0.0 | ||
var base_bgm_db := 0.0 | ||
|
||
func play_sfx(sfx: AudioStream, db: float = 0.0): | ||
var sfx_player := AudioStreamPlayer.new() | ||
self.add_child(sfx_player) | ||
|
||
sfx_player.stream = sfx | ||
sfx_player.volume_db = db | ||
sfx_player.bus = "sfx" | ||
sfx_player.play() | ||
sfx_player.finished.connect(sfx_player.queue_free.bind()) | ||
|
||
func play_bgm(bgm: AudioStream, db: float = 0.0): | ||
var bgm_player := AudioStreamPlayer.new() | ||
self.add_child(bgm_player) | ||
|
||
bgm_player.stream = bgm | ||
bgm_player.volume_db = db | ||
bgm_player.bus = "bgm" | ||
bgm_player.play() | ||
bgm_player.loop = true |