GLOBAL gd attached to AutoLoad extends Node var childName var childSiz

 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
59
60
61
62
# GLOBAL.gd attached to AutoLoad
extends Node
var childName
var childSize
var scene1 = preload("res://test_child1.tscn")
var scene2 = preload("res://test_child2.tscn")
var scene3 = preload("res://test_child3.tscn")
# BUILD.gd
extends Control
func _ready():
($currentModule).add_child(GLOBAL.scene1.instance())
GLOBAL.childName = $currentModule.get_child(0).name
#print(GLOBAL.childName)
GLOBAL.childSize = $currentModule.get_node(GLOBAL.childName).get_node("Panel").rect_size / 2
GLOBAL.scene1.instance().position = OS.get_window_size() / 2 - GLOBAL.childSize
# Child scenes .gd named accordingly
extends Node2D
func _ready():
self.position = get_viewport().size / 2 - $Panel.rect_size / 2
func _on_bttn_toScene2_button_up():
get_tree().root.get_node("BUILD/currentModule").add_child(GLOBAL.scene2.instance())
GLOBAL.childName = get_node("..").get_child(1).name
print(GLOBAL.childName)
get_parent().remove_child(self)
queue_free() #Debugger-Monitor showed memory does add up until the idle instance is freed
func _on_bttn_toScene3_button_up():
get_tree().root.get_node("BUILD/currentModule").add_child(GLOBAL.scene3.instance())
GLOBAL.childName = get_node("..").get_child(1).name
print(GLOBAL.childName)
get_parent().remove_child(self)
queue_free()
.