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
+2 -1
View File
@@ -1,4 +1,5 @@
extends Control
# Load scene warcraft
func _on_WarCraft_pressed():
get_tree().change_scene("res://scenes/levels/WarCraft.tscn")
Global.goto_scene("res://scenes/levels/WarCraft.tscn")
+11 -4
View File
@@ -6,13 +6,20 @@
[node name="ChooseScene" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 200.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GridContainer" type="GridContainer" parent="."]
[node name="games" type="Control" parent="."]
margin_left = 200.0
margin_right = 1024.0
margin_bottom = 600.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GridContainer" type="GridContainer" parent="games"]
margin_left = 25.0
margin_top = 26.2599
margin_right = 824.0
@@ -21,10 +28,10 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="WarCraft" type="TextureButton" parent="GridContainer"]
[node name="WarCraft" type="TextureButton" parent="games/GridContainer"]
margin_right = 150.0
margin_bottom = 150.0
mouse_default_cursor_shape = 2
texture_normal = ExtResource( 2 )
[connection signal="pressed" from="GridContainer/WarCraft" to="." method="_on_WarCraft_pressed"]
[connection signal="pressed" from="games/GridContainer/WarCraft" to="." method="_on_WarCraft_pressed"]
+10 -4
View File
@@ -1,9 +1,15 @@
extends Spatial
export (PackedScene) var main = load("res://scenes/main.tscn")
func _process(_delta):
# Event key "escape" and "godot event" ui_end
if Input.is_action_just_pressed("ui_end"):
_quit_to_menu()
func _notification(what):
# Back to main scene
# Notification for android back action
if what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
var scene = main.instance()
call_deferred("add_child", scene)
_quit_to_menu()
# Back to main scene
func _quit_to_menu():
Global.goto_scene("res://scenes/main.tscn")
+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")