scene transitions

This commit is contained in:
Leon Palluch committed 2020-02-01 18:36:42 +01:00
1 parent 07d2eb94ce
commit 1690239782
7 files changed
+1128 -27

No files matched your search

+52 -16
View File
@@ -1,41 +1,77 @@
extends Node
var _win_screen_scene
var _fighting_scene_path = "res://Ingame/Testing.tscn"
var _fighting_scene
const _body_build_path = "res://BodyConfig/bodyBuilderMenu.tscn"
const _fighting_path = "res://Ingame/Testing.tscn"
const _win_screen_path = "res://UI/WinScreen.tscn"
var _body_build_scene
var _fighting_scene
var _win_screen_scene
#test
var test = 0
var tested = false
signal player_win()
func _ready():
_win_screen_scene = preload("res://UI/WinScreen.tscn").instance()
_body_build_scene = preload("res://BodyConfig/bodyBuilderMenu.tscn").instance()
_fighting_scene = preload("res://Ingame/Testing.tscn").instance()
_prep_scene("body_build")
_prep_scene("fight_scene")
_prep_scene("win_screen")
InGameState.connect("player_win", self, "_switch_to_win")
_body_build_scene.connect("start_fight", self, "_switch_to_fighting")
_win_screen_scene.connect("build_body", self, "_switch_to_body_build")
#test
connect("player_win", self, "_switch_to_win")
_switch_scene(_body_build_scene, "body_build")
func _switch_scene(scene):
func _prep_scene(scene_name) -> Node:
if scene_name == "body_build":
_body_build_scene = preload(_body_build_path).instance()
_body_build_scene.connect("start_fight", self, "_switch_to_fighting")
return _body_build_scene
elif scene_name == "fight_scene":
_fighting_scene = preload(_fighting_path).instance()
InGameState.connect("player_win", self, "_switch_to_win")
return _fighting_scene
elif scene_name == "win_screen":
_win_screen_scene = preload(_win_screen_path).instance()
_win_screen_scene.connect("build_body", self, "_switch_to_body_build")
return _win_screen_scene
return null
func _switch_scene(scene, scene_name):
#delete children
for child in get_children():
child.queue_free()
#append win scene
add_child(scene)
var new_scene = _prep_scene(scene_name)
add_child(new_scene)
func _switch_to_win(player_id):
_switch_scene(_win_screen_scene)
print("test win")
_switch_scene(_win_screen_scene, "win_screen")
#call win message in win scene
_win_screen_scene.set_win_message(player_id)
func _switch_to_fighting():
print("oh fuck")
test = 0
tested = false
_switch_scene(_fighting_scene)
#get_tree().reload_current_scene()
_switch_scene(_fighting_scene, "fight_scene")
func _switch_to_body_build():
_switch_scene(_body_build_scene)
_switch_scene(_body_build_scene, "body_build")
func _process(delta):
if not tested:
test += delta
if test > 3:
print("test2")
tested = true
emit_signal("player_win", 1)
+1 -4
View File
@@ -1,9 +1,6 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Controllers/GameStateController.gd" type="Script" id=1]
[ext_resource path="res://BodyConfig/bodyBuilderMenu.tscn" type="PackedScene" id=2]
[node name="GameStateController" type="Node"]
script = ExtResource( 1 )
[node name="Body Builder Menu" parent="." instance=ExtResource( 2 )]