forked from godotneers/saving-loading-video
-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.gd
41 lines (26 loc) · 898 Bytes
/
game.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
extends Node2D
@onready var _world_root:WorldRoot = %WorldRoot
@onready var _saver_loader:SaverLoader = %SaverLoader
@onready var _pause_screen = %PauseScreen
var _paused:bool = false
func _ready():
_world_root.level_exit_reached.connect(_on_level_exit_reached)
func _on_level_exit_reached(next_level):
_world_root.load_level_async(next_level)
func _process(_delta):
if Input.is_action_just_pressed("pause"):
_pause(not _paused)
func _pause(value:bool):
_paused = value
_pause_screen.visible = _paused
get_tree().paused = _paused
## ------------------------------------------------------------------------------------
# Called when the save game button is pressed
func _on_save_game():
print("Save game!")
_saver_loader.save_game()
# Called when the load game button is pressed
func _on_load_game():
print("Load game!")
_saver_loader.load_game()
# _pause(true)