feat: Support WAV files as well (#469)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-11-28 15:36:50 +01:00
committed by GitHub
parent 55e2ed5e59
commit 0e295f0ebb
7 changed files with 38 additions and 3 deletions

View File

@@ -39,7 +39,11 @@ func set_state(p_state: String, p_force: bool = false) -> void:
stream.stream = resource
if stream.stream:
resource.set_loop(true)
if resource is AudioStreamSample:
resource.loop_mode = AudioStreamSample.LOOP_FORWARD
resource.loop_end = resource.mix_rate * resource.get_length()
elif "loop" in resource:
resource.loop = true
if ProjectSettings.has_setting("escoria/sound/music_volume"):
stream.volume_db = ProjectSettings.get_setting("escoria/sound/music_volume")
stream.play()

View File

@@ -39,7 +39,10 @@ func set_state(p_state: String, p_force: bool = false):
stream.stream = resource
if stream.stream:
resource.set_loop(false)
if resource is AudioStreamSample:
resource.loop_mode = AudioStreamSample.LOOP_DISABLED
elif "loop" in resource:
resource.loop = false
if ProjectSettings.has_setting("escoria/sound/sound_volume"):
stream.volume_db = ProjectSettings.get_setting("escoria/sound/sound_volume")
stream.play()

View File

@@ -0,0 +1,3 @@
:use
play_snd res://game/sfx/sounds/bird-honk.wav

View File

@@ -0,0 +1,3 @@
:use
play_snd res://game/sfx/sounds/bird-honk.wav _music

View File

@@ -0,0 +1,3 @@
:use
stop_snd _music

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=11 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_terrain.gd" type="Script" id=1]
[ext_resource path="res://game/rooms/room13/background.tscn" type="PackedScene" id=2]
@@ -7,6 +7,7 @@
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=6]
[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=7]
[ext_resource path="res://game/items/escitems/button.tscn" type="PackedScene" id=8]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 1168.92, 640.557, 1182.53, 588.863, 1269.59, 622.872, 1275.03, 799.721, 864.626, 613.518, 1143.08, 613.35, -9.16094, 803.802, 386.666, 618.012, 129.634, 615.792, 84.5821, 654.06, -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698 )
@@ -103,3 +104,21 @@ polygon = PoolVector2Array( 11.9329, 46.7699, 15.928, 354.381, 118.798, 416.303,
[node name="Position2D" type="Position2D" parent="Hotspots/r_door"]
position = Vector2( 60.9229, 371.53 )
[node name="play_wav" parent="Hotspots" instance=ExtResource( 8 )]
position = Vector2( -172.899, -45.2554 )
global_id = "play_wav"
esc_script = "res://game/rooms/room13/esc/play_wav.esc"
tooltip_name = "Play WAV"
[node name="play_wav_loop" parent="Hotspots" instance=ExtResource( 8 )]
position = Vector2( -173.479, 43.5148 )
global_id = "play_wav_loop"
esc_script = "res://game/rooms/room13/esc/play_wav_loop.esc"
tooltip_name = "Play WAV Loop"
[node name="stop_loop" parent="Hotspots" instance=ExtResource( 8 )]
position = Vector2( -173.479, 132.865 )
global_id = "stop_loop"
esc_script = "res://game/rooms/room13/esc/stop_loop.esc"
tooltip_name = "Stop Looping"

Binary file not shown.