From aed0f952c7170bf71a79de323e6aa85b56f3b8ba Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Sun, 24 Jan 2021 15:50:47 +1030 Subject: [PATCH] Add music node to singleton --- RadialGame.tscn | 8 +++----- scripts/NoteHandler.gd | 2 +- singletons/SFXPlayer.gd | 7 +++++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/RadialGame.tscn b/RadialGame.tscn index e43db5c..0644ed4 100644 --- a/RadialGame.tscn +++ b/RadialGame.tscn @@ -28,7 +28,7 @@ shader_param/px = 0.00108696 shader_param/px2 = 0.00217391 shader_param/alpha = 1.0 -[sub_resource type="ArrayMesh" id=2] +[sub_resource type="ArrayMesh" id=7] surfaces/0 = { "aabb": AABB( -481.834, -481.834, 0, 963.667, 963.667, 0 ), "array_data": PoolByteArray( 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0, 95, 168, 216, 67, 118, 207, 152, 66, 137, 59, 80, 49, 183, 65, 237, 67, 202, 86, 167, 66, 32, 60, 210, 49, 125, 187, 206, 67, 38, 125, 22, 67, 48, 59, 60, 53, 64, 99, 226, 67, 249, 203, 36, 67, 223, 59, 187, 53, 141, 134, 190, 67, 0, 0, 92, 67, 160, 58, 166, 55, 217, 163, 208, 67, 177, 234, 112, 67, 65, 59, 48, 56, 159, 135, 168, 67, 204, 105, 141, 67, 220, 57, 235, 56, 142, 141, 184, 67, 186, 219, 154, 67, 107, 58, 98, 57, 204, 105, 141, 67, 159, 135, 168, 67, 235, 56, 220, 57, 186, 219, 154, 67, 142, 141, 184, 67, 98, 57, 107, 58, 0, 0, 92, 67, 141, 134, 190, 67, 166, 55, 160, 58, 177, 234, 112, 67, 217, 163, 208, 67, 48, 56, 65, 59, 38, 125, 22, 67, 125, 187, 206, 67, 60, 53, 48, 59, 249, 203, 36, 67, 64, 99, 226, 67, 187, 53, 223, 59, 118, 207, 152, 66, 95, 168, 216, 67, 80, 49, 137, 59, 202, 86, 167, 66, 183, 65, 237, 67, 210, 49, 32, 60, 141, 172, 242, 40, 0, 0, 220, 67, 0, 0, 166, 59, 143, 223, 4, 41, 177, 234, 240, 67, 0, 0, 48, 60, 118, 207, 152, 194, 95, 168, 216, 67, 80, 177, 137, 59, 202, 86, 167, 194, 183, 65, 237, 67, 210, 177, 32, 60, 38, 125, 22, 195, 125, 187, 206, 67, 60, 181, 48, 59, 249, 203, 36, 195, 64, 99, 226, 67, 187, 181, 223, 59, 0, 0, 92, 195, 141, 134, 190, 67, 166, 183, 160, 58, 177, 234, 112, 195, 217, 163, 208, 67, 48, 184, 65, 59, 204, 105, 141, 195, 159, 135, 168, 67, 235, 184, 220, 57, 186, 219, 154, 195, 142, 141, 184, 67, 98, 185, 107, 58, 159, 135, 168, 195, 204, 105, 141, 67, 220, 185, 235, 56, 142, 141, 184, 195, 186, 219, 154, 67, 107, 186, 98, 57, 141, 134, 190, 195, 0, 0, 92, 67, 160, 186, 166, 55, 217, 163, 208, 195, 177, 234, 112, 67, 65, 187, 48, 56, 125, 187, 206, 195, 38, 125, 22, 67, 48, 187, 60, 53, 64, 99, 226, 195, 249, 203, 36, 67, 223, 187, 187, 53, 95, 168, 216, 195, 118, 207, 152, 66, 137, 187, 80, 49, 183, 65, 237, 195, 202, 86, 167, 66, 32, 188, 210, 49, 0, 0, 220, 195, 141, 172, 114, 41, 166, 187, 0, 0, 177, 234, 240, 195, 143, 223, 132, 41, 48, 188, 0, 0, 95, 168, 216, 195, 118, 207, 152, 194, 137, 187, 80, 177, 183, 65, 237, 195, 202, 86, 167, 194, 32, 188, 210, 177, 125, 187, 206, 195, 38, 125, 22, 195, 48, 187, 60, 181, 64, 99, 226, 195, 249, 203, 36, 195, 223, 187, 187, 181, 141, 134, 190, 195, 0, 0, 92, 195, 160, 186, 166, 183, 217, 163, 208, 195, 177, 234, 112, 195, 65, 187, 48, 184, 159, 135, 168, 195, 204, 105, 141, 195, 220, 185, 235, 184, 142, 141, 184, 195, 186, 219, 154, 195, 107, 186, 98, 185, 204, 105, 141, 195, 159, 135, 168, 195, 235, 184, 220, 185, 186, 219, 154, 195, 142, 141, 184, 195, 98, 185, 107, 186, 0, 0, 92, 195, 141, 134, 190, 195, 166, 183, 160, 186, 177, 234, 112, 195, 217, 163, 208, 195, 48, 184, 65, 187, 38, 125, 22, 195, 125, 187, 206, 195, 60, 181, 48, 187, 249, 203, 36, 195, 64, 99, 226, 195, 187, 181, 223, 187, 118, 207, 152, 194, 95, 168, 216, 195, 80, 177, 137, 187, 202, 86, 167, 194, 183, 65, 237, 195, 210, 177, 32, 188, 106, 1, 182, 169, 0, 0, 220, 195, 0, 0, 166, 187, 87, 79, 199, 169, 177, 234, 240, 195, 0, 0, 48, 188, 118, 207, 152, 66, 95, 168, 216, 195, 80, 49, 137, 187, 202, 86, 167, 66, 183, 65, 237, 195, 210, 49, 32, 188, 38, 125, 22, 67, 125, 187, 206, 195, 60, 53, 48, 187, 249, 203, 36, 67, 64, 99, 226, 195, 187, 53, 223, 187, 0, 0, 92, 67, 141, 134, 190, 195, 166, 55, 160, 186, 177, 234, 112, 67, 217, 163, 208, 195, 48, 56, 65, 187, 204, 105, 141, 67, 159, 135, 168, 195, 235, 56, 220, 185, 186, 219, 154, 67, 142, 141, 184, 195, 98, 57, 107, 186, 159, 135, 168, 67, 204, 105, 141, 195, 220, 57, 235, 184, 142, 141, 184, 67, 186, 219, 154, 195, 107, 58, 98, 185, 141, 134, 190, 67, 0, 0, 92, 195, 160, 58, 166, 183, 217, 163, 208, 67, 177, 234, 112, 195, 65, 59, 48, 184, 125, 187, 206, 67, 38, 125, 22, 195, 48, 59, 60, 181, 64, 99, 226, 67, 249, 203, 36, 195, 223, 59, 187, 181, 95, 168, 216, 67, 118, 207, 152, 194, 137, 59, 80, 177, 183, 65, 237, 67, 202, 86, 167, 194, 32, 60, 210, 177, 0, 0, 220, 67, 0, 0, 0, 0, 166, 59, 0, 0, 177, 234, 240, 67, 0, 0, 0, 0, 48, 60, 0, 0 ), @@ -84,9 +84,6 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="music" type="AudioStreamPlayer" parent="."] -bus = "Music" - [node name="video" type="VideoPlayer" parent="."] anchor_left = 0.5 anchor_top = 0.5 @@ -127,13 +124,14 @@ __meta__ = { [node name="Receptors" type="MeshInstance2D" parent="Center"] material = SubResource( 1 ) -mesh = SubResource( 2 ) +mesh = SubResource( 7 ) script = ExtResource( 9 ) [node name="Tween" type="Tween" parent="Center/Receptors"] [node name="NoteHandler" type="Node2D" parent="Center"] script = ExtResource( 8 ) +MusicPlayerPath = NodePath("") [node name="Viewport" type="Viewport" parent="Center/NoteHandler"] size = Vector2( 1080, 1080 ) diff --git a/scripts/NoteHandler.gd b/scripts/NoteHandler.gd index 28b4107..f043410 100644 --- a/scripts/NoteHandler.gd +++ b/scripts/NoteHandler.gd @@ -10,7 +10,7 @@ var song_key = '' export var MusicPlayerPath := @'../../music' export var VideoPlayerPath := @'../../video' export var InputHandlerPath := @'../../InputHandler' -onready var MusicPlayer := get_node(MusicPlayerPath) +onready var MusicPlayer := SFXPlayer.music_player onready var VideoPlayer := get_node(VideoPlayerPath) onready var InputHandler := get_node(InputHandlerPath) diff --git a/singletons/SFXPlayer.gd b/singletons/SFXPlayer.gd index b8db072..54baf5c 100644 --- a/singletons/SFXPlayer.gd +++ b/singletons/SFXPlayer.gd @@ -36,3 +36,10 @@ func play(type: int, parent: Node, stream: AudioStream, volume_db: float = 0.0, audio_stream_player.pitch_scale = pitch_scale audio_stream_player.play() audio_stream_player.connect("finished", audio_stream_player, "queue_free") + + +# This singleton and API will need renaming later to reflect the new purposes +var music_player := AudioStreamPlayer.new() +func _ready() -> void: + add_child(music_player) + music_player.bus = "Music"