-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaused.gd
More file actions
31 lines (27 loc) · 862 Bytes
/
Paused.gd
File metadata and controls
31 lines (27 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
extends Node2D
var paused : bool = false
func _process(_delta : float) -> void:
if Input.is_action_just_pressed("pause"):
if paused:
visible = false
paused = false
get_tree().paused = false
if Global.relative_mouse:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED_HIDDEN)
$VBoxContainer/HBoxContainer/Quit.release_focus()
EventBus.unpaused.emit()
else:
EventBus.paused.emit()
visible = true
paused = true
get_tree().paused = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
$VBoxContainer/HBoxContainer/Quit.grab_focus()
if Input.is_action_just_pressed("mute"):
AudioServer.set_bus_mute(0, !AudioServer.is_bus_mute(0))
func _on_quit_pressed() -> void:
paused = false
get_tree().paused = false
get_tree().change_scene_to_packed(Scenes.MainMenu)