godot-game-template
godot-game-template copied to clipboard
Idea: allow loader stages after scene loads, before it starts
Idea:
After pre_start
, but before start
the scene can add more "in-scene" stages to the progress-bar.
I think the pre_start function can be used for this, and maybe using yield
to advance the progress bar (coroutines style) or by emitting signals.
I guess that in order to have proper progress-bar the number of "in-scene" stages need to be known before the scene is loaded, which is tricky, a simple solution is to pass it in the params, but I hope there is a more elegant solution.
Example use case: The gameplay.tscn scene generates procedural level in the pre_start func
func start_button_pressed():
Game.change_scene("res://gameplay.tscn",
{ "show_progress_bar": true,
"in_scene_stages": 5 # tell the progess bar to reserve 5 extra stages
})
# in gameplay.gd
func pre_start(params):
generate_maze()
yield() # advance stage... or use signal and wait for idle frame?
generate_tiles()
yield()
generate_treasure()
yield()
generate_monsters()
yield()
generate_doors()
func start():
play_start_game_sound()
Hi @Iftahh, thanks for taking time explaining your suggestion!
I would split the problem in 2 separate issues:
- generic loader stages (this issue, harder to solve)
- improving
pre_start()
behaviour on scene loading (https://github.com/crystal-bit/godot-game-template/issues/66 a simpler issue that could be fixed quickly in themain
branch)