Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: allow loader stages after scene loads, before it starts #65

Open
Iftahh opened this issue Apr 10, 2022 · 1 comment
Open

Idea: allow loader stages after scene loads, before it starts #65

Iftahh opened this issue Apr 10, 2022 · 1 comment

Comments

@Iftahh
Copy link

Iftahh commented Apr 10, 2022

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()
@davcri
Copy link
Member

davcri commented Apr 11, 2022

Hi @Iftahh, thanks for taking time explaining your suggestion!

I would split the problem in 2 separate issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants