Loading resources frame by frame instead of instantly

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

I have 5 spritesheets that have to be loaded when I call a function but the game freezes for like 0.50 sec beacuse loading all at once, how do I achieve loading these spritesheets frame by frame or over a given time?

:bust_in_silhouette: Reply From: DiMiMi

Create a loop and write something like yield(get_tree().create_timer(0.5), "timeout") at the end. This way, the script will pause for 0.5 seconds (or any time you want) and will proceed when the time is over. You could probably also use yield(get_tree(), "idle_frame") or yield(get_tree(), "physics_frame"). This will pause your script till the next “_process” or “_physics_process” step will accur.

This seems like a very good solution for this but is this compatible with how load function works?

Zuckey | 2020-10-22 11:41

I found exactly the thing you were searching for (ResourceInteractiveLoader):
Background loading — Godot Engine (stable) documentation in English

DiMiMi | 2020-10-22 14:46

I think I have seen this before but I was very inexperienced then, this is really helpful right now thank you!

Zuckey | 2020-10-22 18:33