Add loading when load warcraft scene

This commit is contained in:
VAILLANT Jeremy
2021-05-09 17:10:40 +02:00
parent 275c0a080f
commit 78b566f5b8
4 changed files with 31 additions and 17 deletions
+8 -8
View File
@@ -3,7 +3,7 @@ extends Node
export (PackedScene) var about = load("res://scenes/UI/About.tscn")
export (PackedScene) var scenes = load("res://scenes/UI/ChooseScene.tscn")
var scene
var current_scene = null
# Quit the game
func _on_Quit_pressed():
@@ -12,17 +12,17 @@ func _on_Quit_pressed():
# Load scene about
func _on_About_pressed():
_prepare_change_scene()
scene = about.instance()
add_child(scene)
current_scene = about.instance()
add_child(current_scene)
# Load scene for select game
func _on_New_pressed():
_prepare_change_scene()
scene = scenes.instance()
add_child(scene)
current_scene = scenes.instance()
add_child(current_scene)
## PRIVATE
func _prepare_change_scene():
if (scene != null):
remove_child(scene)
scene.call_deferred("free")
if (current_scene != null):
remove_child(current_scene)
current_scene.call_deferred("free")