diff --git a/src/game/game.gd b/src/game/game.gd index 732e601..fd46b50 100644 --- a/src/game/game.gd +++ b/src/game/game.gd @@ -6,6 +6,7 @@ class_name Game extends Node var _loading_resources := {} @onready var viewport: GameViewportContainer = %ViewportContainer +@onready var sfx: GameSFX = %SFX @onready var content: Node = %Content @onready var loader_transition: AnimationPlayer = %LoaderTransition diff --git a/src/game/game.tscn b/src/game/game.tscn index 011d726..293e9b4 100644 --- a/src/game/game.tscn +++ b/src/game/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://cefit4bc8akbb"] +[gd_scene load_steps=13 format=3 uid="uid://cefit4bc8akbb"] [ext_resource type="Script" path="res://src/game/game.gd" id="1_4qa87"] [ext_resource type="FontFile" uid="uid://dsa0oh7c0h4pu" path="res://assets/fonts/Racing_Sans_One/RacingSansOne-Regular.ttf" id="2_y3adf"] @@ -6,6 +6,8 @@ [ext_resource type="Script" path="res://src/ui/game_viewport_container.gd" id="3_rmm5i"] [ext_resource type="Script" path="res://src/game/game_viewport.gd" id="5_v2qv5"] [ext_resource type="Script" path="res://src/util/debug_version_info.gd" id="6_42bd1"] +[ext_resource type="Script" path="res://src/game/sfx.gd" id="7_xpf8p"] +[ext_resource type="AudioStream" uid="uid://8uynlpios7u1" path="res://assets/sound/sfx/ui/ecofuture2.wav" id="8_ab8py"] [sub_resource type="Animation" id="Animation_c3dlb"] length = 0.001 @@ -238,3 +240,12 @@ script = ExtResource("5_v2qv5") [node name="Content" type="Node" parent="RootControl/Rumbler/ViewportContainer/Viewport"] unique_name_in_owner = true process_mode = 1 + +[node name="SFX" type="Node" parent="."] +unique_name_in_owner = true +script = ExtResource("7_xpf8p") + +[node name="Chime" type="AudioStreamPlayer" parent="SFX"] +unique_name_in_owner = true +stream = ExtResource("8_ab8py") +bus = &"SFX" diff --git a/src/game/sfx.gd b/src/game/sfx.gd new file mode 100644 index 0000000..4fcba8d --- /dev/null +++ b/src/game/sfx.gd @@ -0,0 +1,4 @@ +class_name GameSFX extends Node +## Container & accessor for game-global SFX + +@onready var chime: AudioStreamPlayer = %Chime diff --git a/src/ui/menus/title_screen/title_screen.gd b/src/ui/menus/title_screen/title_screen.gd index de58cf2..fd02f34 100644 --- a/src/ui/menus/title_screen/title_screen.gd +++ b/src/ui/menus/title_screen/title_screen.gd @@ -14,13 +14,13 @@ const SCENE := "res://src/ui/menus/title_screen/title_screen.tscn" @onready var state_machine: AnimationTree = $Menu/MenuStateMachine @onready var menu_state: AnimationNodeStateMachinePlayback = state_machine["parameters/playback"] -@onready var confirm_sfx: AudioStreamPlayer = %ConfirmSFX - @onready var idle_timer: Timer = %IdleTimer +@onready var game: Game = get_tree().get_first_node_in_group(Game.group) + func play_chime() -> void: - confirm_sfx.play() + game.sfx.chime.play() func start_title_crawl() -> void: diff --git a/src/ui/menus/title_screen/title_screen.tscn b/src/ui/menus/title_screen/title_screen.tscn index 507bed3..01f5b40 100644 --- a/src/ui/menus/title_screen/title_screen.tscn +++ b/src/ui/menus/title_screen/title_screen.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=87 format=3 uid="uid://7fsgocmdas7i"] +[gd_scene load_steps=86 format=3 uid="uid://7fsgocmdas7i"] [ext_resource type="Script" path="res://src/ui/menus/title_screen/title_screen.gd" id="1_2qtlb"] [ext_resource type="Texture2D" uid="uid://880x5n8j3b5l" path="res://assets/logo/title.png" id="1_pm82i"] @@ -6,7 +6,6 @@ [ext_resource type="Texture2D" uid="uid://clesl8lljs6of" path="res://assets/logo/subtitle.png" id="2_y0ulk"] [ext_resource type="PackedScene" uid="uid://ccx2u5oli6men" path="res://src/ui/menus/title_screen/deathmatch_setup/deathmatch_setup.tscn" id="3_bo4ty"] [ext_resource type="Material" uid="uid://dpsmjlhjpc7vs" path="res://assets/materials/basic_ball_material.tres" id="5_5q83g"] -[ext_resource type="AudioStream" uid="uid://8uynlpios7u1" path="res://assets/sound/sfx/ui/ecofuture2.wav" id="5_fg1a4"] [ext_resource type="PackedScene" uid="uid://cqu315hviu72n" path="res://src/ui/menus/title_screen/title_crawl.tscn" id="7_r26eu"] [sub_resource type="Environment" id="Environment_ardux"] @@ -250,25 +249,16 @@ tracks/1/path = NodePath("../../..") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0.6), -"transitions": PackedFloat32Array(1), +"times": PackedFloat32Array(0, 0.6), +"transitions": PackedFloat32Array(1, 1), "values": [{ "args": [], +"method": &"play_chime" +}, { +"args": [], "method": &"_on_quit" }] } -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("%ConfirmSFX:playing") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 1, -"values": [true] -} [sub_resource type="AnimationLibrary" id="AnimationLibrary_cgw58"] _data = { @@ -1490,7 +1480,7 @@ grow_horizontal = 2 grow_vertical = 2 [node name="PressStart" type="Label" parent="Menu"] -modulate = Color(1, 1, 1, 0.0413553) +modulate = Color(1, 1, 1, 0.0024811) layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -1703,11 +1693,6 @@ libraries = { } autoplay = "press_start_fade_in" -[node name="ConfirmSFX" type="AudioStreamPlayer" parent="."] -unique_name_in_owner = true -stream = ExtResource("5_fg1a4") -bus = &"SFX" - [node name="SettingsContainer" type="MarginContainer" parent="."] unique_name_in_owner = true layout_mode = 1