Refactor Scene management #1
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
refactor
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
abgit/MirrorMirror#1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Scene managment system
Every minigame scene is loaded one after another with the
loadNextScene()function.This function is implemented independently in each minigame main script.
Eg:
The plan is to create a global scene handler.
2 possible ways i see :
loadScene(scenePath)functionloadNextScene()that gets the top of the queue and loads itThe scene handler could use a signal so that minigames can notify when to load the next scene.
Files impacted :
cutMirror.gdmeltSand.gdpainting_canvas.gdruneGame.gdsmashGlass.gdstart_scene.gdshopping.gdI think this is the way to go as it would be a pain to change the order of the scenes if we add one in the middle of it for example
Ressources
Commit
a57a973d16Changelog:
signal sceneEnded()to signals.gdstart_scene.gdemitssceneEndedget_tree().change_scene_to_file(res://...)As you might have seen, this creates lots of things to change since the "scene" doesnt change in the current state, it removes and child and adds another scene as a child, this allows to keep the UI consistent throughout the gameplay/music/pause menu etc
Maybe the simplest way might be to doget_tree().get_child().change_scene_to_file()with a number (2 or 3 depending on how many global variables are declared) given toget_child()I'll check it out tomorrow
Commit
91badf90ccChangelog:
GameInterfacescene toshopping.tscnandmeltSand.tscn, I did it manually but it could be added programmatically and it might be better. (This allows us to still use the pause menu and to actually have a game interface : The progress bar and the money amount for example)scenePaths[]in sceneHandler.gd to test my system, an index that starts at 1 (0 is the main menu) is incremented each time after switching to next scene from_on_scene_ended(), if index overflows, it goes back to 1 (the scene with the witches)After some experimentation, I think the GameInterface scene should be added as a child to a global node on the launch of the game instead of as a sibling or child in a scene. I'm not entirely sure so if it's alright with you we'll talk about it.
My work is getting messy so I won't push it yet but I'll probably work on it tomorrow. In any case I think this is mostly solved