-
Notifications
You must be signed in to change notification settings - Fork 0
/
paused.gd
52 lines (42 loc) · 1.34 KB
/
paused.gd
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
extends Panel
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func _input(event:InputEvent) -> void:
if event is InputEventKey:
if Input.is_key_pressed(KEY_ESCAPE):
##save()
get_parent().save()
if get_meta("paused"):
_on_resume_pressed()
else:
get_tree().change_scene_to_file("res://StartMenu.tscn")
func pauseGame() -> void:
get_parent().get_node("Countdown").set_meta("start", false)
get_parent().save()
get_parent().get_node("Countdown").hide()
get_parent().get_node("Paused").visible = true
get_tree().paused = true
func _on_resume_pressed() -> void:
get_tree().paused = false
get_parent().get_node("Countdown").show()
get_parent().get_node("Paused").visible = false
set_meta("paused", false)
func _notification(what):
if what == NOTIFICATION_WM_GO_BACK_REQUEST:
##save()
get_parent().save()
if get_meta("paused"):
_on_resume_pressed()
else:
get_tree().change_scene_to_file("res://StartMenu.tscn")
if what == NOTIFICATION_WM_CLOSE_REQUEST:
if ! get_parent().get_node("Lost").get_meta("lost"):
##save()
get_parent().save()
get_tree().quit()
if what == MainLoop.NOTIFICATION_APPLICATION_FOCUS_OUT:
# goes to background
if ! get_parent().get_node("Lost").get_meta("lost"):
set_meta("paused", true)
pauseGame()