Moves stuff around, made a main menu and scene mgr
This commit is contained in:
parent
b2e3a3957b
commit
6c023a60a6
37 changed files with 888 additions and 214 deletions
32
stages/SceneManager/scripts/scene_manager.gd
Normal file
32
stages/SceneManager/scripts/scene_manager.gd
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
extends Node3D
|
||||
class_name SceneManager
|
||||
|
||||
const SCENES: Dictionary = {
|
||||
"MAINMENU": "res://Stages/MainMenu/MainMenu.tscn",
|
||||
"HIGHSCORES": "res://scenes/high_scores.tscn"
|
||||
}
|
||||
|
||||
var loading_scene_res: Resource = null
|
||||
|
||||
func _ready() -> void:
|
||||
## LOAD GAME DATA
|
||||
#HighScoreMgr.load()
|
||||
#HighScoreMgr.debug_output()
|
||||
# HighScoreMgr.debug_save_high_score()
|
||||
Log.pr("SceneManager is ready.")
|
||||
SceneMgr.connect("change_scene", Callable(self, "_on_change_scene"))
|
||||
$TransitionScene.connect("transitioned", Callable(self, "_on_transition_scene_transitioned"))
|
||||
|
||||
func _on_change_scene(scene_name: String) -> void:
|
||||
Log.pr("Going to load a scene.", scene_name)
|
||||
if SCENES.has(scene_name):
|
||||
#GameState.reset()
|
||||
loading_scene_res = load(SCENES[scene_name])
|
||||
Log.pr("Loading scene: ", loading_scene_res)
|
||||
$TransitionScene.transition()
|
||||
else:
|
||||
loading_scene_res = null
|
||||
|
||||
func _on_transition_scene_transitioned() -> void:
|
||||
$CurrentScene.get_child(0).queue_free()
|
||||
$CurrentScene.add_child(loading_scene_res.instantiate())
|
||||
1
stages/SceneManager/scripts/scene_manager.gd.uid
Normal file
1
stages/SceneManager/scripts/scene_manager.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bqtnrs6cjoyj6
|
||||
18
stages/SceneManager/scripts/transition_scene.gd
Normal file
18
stages/SceneManager/scripts/transition_scene.gd
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
extends CanvasLayer
|
||||
|
||||
signal transitioned
|
||||
|
||||
func _ready() -> void:
|
||||
$AnimationPlayer.play("fade_to_normal")
|
||||
|
||||
func transition() -> void:
|
||||
$AnimationPlayer.play("fade_to_black")
|
||||
Log.pr("Fading to black")
|
||||
|
||||
func _on_animation_player_animation_finished(anim_name: StringName) -> void:
|
||||
if anim_name == "fade_to_black":
|
||||
Log.pr("Sending transitioned signal...")
|
||||
emit_signal("transitioned")
|
||||
$AnimationPlayer.play("fade_to_normal")
|
||||
if anim_name == "fade_to_normal":
|
||||
Log.pr("Faded to normal")
|
||||
1
stages/SceneManager/scripts/transition_scene.gd.uid
Normal file
1
stages/SceneManager/scripts/transition_scene.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cem1lps8uxlya
|
||||
Loading…
Add table
Add a link
Reference in a new issue