call_deferred and add_child

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CalmTurtle


Ever see one of those awesome dungeon generators that paints the tiles one by one for you to view in amazement? If not, check it out: Awesome Dungeon Generator

My question is in Godot, how to I manage to add_child one by one so they appear on screen one by one. I have tried a few different approaches without success.

  1. My tile generator being call_deferred and my tile painter (the function that adds children) on the main thread.

  2. Tile painter on call_deferred and tile generator on main thread.

  3. Both the tile generator and the tile painter on main thread and both on call_deferred

In all cases the function has to finish before the map is displayed and it just updates all at once (no cool tile by tile effect). The trigger is in a button, not in an init or ready.

Thanks for any tips.

:bust_in_silhouette: Reply From: ElefanteNoi

use yield(get_tree(), "idle_frame") inside for,while loop should do the trick