pause music

This commit is contained in:
pennyrigate 2023-10-03 03:55:16 -04:00
parent cf8bfa6210
commit 394f53585e
6 changed files with 50 additions and 6 deletions

View file

@ -13,21 +13,24 @@ func _ready():
if lore_entry != null:
var lore = lore_entry.instance()
lore_container.add_child(lore)
#Pause music
Audio.ac_music.set_stream_paused(true)
Audio.ac_pause_music.play()
func _physics_process(delta):
#Resume with pause button
if Input.is_action_just_pressed("pause"):
queue_free()
get_tree().paused = false
unpause()
Console.print(get_tree().paused)
func _on_Resume_pressed():
get_tree().paused = false
queue_free()
unpause()
func _on_Restart_pressed():
Audio.ac_music.set_stream_paused(false)
Audio.ac_pause_music.stop()
Game.call_deferred("restart_level")
get_tree().paused = false
queue_free()
@ -39,6 +42,8 @@ func _on_Settings_pressed():
func _on_ExitLevel_pressed():
Audio.ac_music.set_stream_paused(false)
Audio.ac_pause_music.stop()
get_tree().paused = false
Game.change_map(load("res://menus/level_select_scholar.tscn"))
yield(Fade, "fade_finished")
@ -49,3 +54,10 @@ func _on_OptionsScreen_exit():
options_screen.visible = false
$LoreContainer.visible = true
$Body/Settings.grab_focus()
func unpause():
get_tree().paused = false
#Stop pause music
Audio.ac_music.set_stream_paused(false)
Audio.ac_pause_music.stop()
queue_free()

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://ui/arrow_figure_8.tres" type="Material" id=1]
[ext_resource path="res://ui/theme.tres" type="Theme" id=2]
@ -8,6 +8,7 @@
[ext_resource path="res://ui/2ndpuberty_outline.tres" type="Material" id=6]
[ext_resource path="res://objects/hud/options_screen.tscn" type="PackedScene" id=7]
[ext_resource path="res://ui/border.png" type="Texture" id=8]
[ext_resource path="res://objects/hud/menu_sounds.tscn" type="PackedScene" id=9]
[node name="PauseScreen" type="CanvasLayer"]
pause_mode = 2
@ -110,8 +111,18 @@ margin_bottom = -14.0
[node name="OptionsScreen" parent="." instance=ExtResource( 7 )]
visible = false
[node name="MenuSounds" parent="." instance=ExtResource( 9 )]
[connection signal="focus_entered" from="Body/Resume" to="MenuSounds" method="play_select_sound"]
[connection signal="pressed" from="Body/Resume" to="." method="_on_Resume_pressed"]
[connection signal="pressed" from="Body/Resume" to="MenuSounds" method="play_confirm_sound"]
[connection signal="focus_entered" from="Body/Restart" to="MenuSounds" method="play_select_sound"]
[connection signal="pressed" from="Body/Restart" to="." method="_on_Restart_pressed"]
[connection signal="pressed" from="Body/Restart" to="MenuSounds" method="play_confirm_sound"]
[connection signal="focus_entered" from="Body/Settings" to="MenuSounds" method="play_select_sound"]
[connection signal="pressed" from="Body/Settings" to="." method="_on_Settings_pressed"]
[connection signal="pressed" from="Body/Settings" to="MenuSounds" method="play_confirm_sound"]
[connection signal="focus_entered" from="Body/ExitLevel" to="MenuSounds" method="play_select_sound"]
[connection signal="pressed" from="Body/ExitLevel" to="." method="_on_ExitLevel_pressed"]
[connection signal="pressed" from="Body/ExitLevel" to="MenuSounds" method="play_confirm_sound"]
[connection signal="exit" from="OptionsScreen" to="." method="_on_OptionsScreen_exit" flags=3]