-
Notifications
You must be signed in to change notification settings - Fork 1
/
game.gd
58 lines (41 loc) · 1.4 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
extends Node
@onready var obj_hold := $ObjectHolder
@onready var curr_scene_hold := $CurrentScene
@onready var transition := $Transition
#@onready var loader := ResourceLoader
var curr_scene : Node
signal scene_spawned(scene: String)
enum SCENE_TRANSITION_TYPE {NORMAL, JUMP}
func _ready():
RenderingServer.set_default_clear_color(Color.BLACK)
change_scene("res://scenes/game/splash/splash.tscn")
func change_scene(scene: String, scene_data: Dictionary = {} ,trans := SCENE_TRANSITION_TYPE.NORMAL) -> void:
match trans:
SCENE_TRANSITION_TYPE.NORMAL:
transition.transition("out")
await transition.trans_anim_done
SCENE_TRANSITION_TYPE.JUMP:
# I mean yeah, of course you do nothing, it's a jump cut
pass
# load and spawn the scene
var scn = load(scene).instantiate()
scn.done.connect(handle_scene_done.bind())
if curr_scene_hold.get_child_count() > 0:
for child in curr_scene_hold.get_children():
child.queue_free()
curr_scene_hold.add_child(scn)
curr_scene = scn
print(scn)
match trans:
SCENE_TRANSITION_TYPE.NORMAL:
transition.transition("in")
await transition.trans_anim_done
SCENE_TRANSITION_TYPE.JUMP:
# I mean yeah, of course you do nothing, it's a jump cut
pass
curr_scene.start(scene_data)
func handle_scene_done(info: Dictionary) -> void:
if info.has("transition"):
change_scene(info.scene, info, info.transition)
else:
change_scene(info.scene, info)