Is there a way to check if a texture is loaded?

Is there a way to check if a texture or a spritesheet is loaded?

I want to make a loading screen and I want to check if all my assets are loaded before starting playing the game.

Did you resolve this? Did you try native.setActivityIndicator?

From the documentation:

native.setActivityIndicator

Displays or hides a platform-specific activity indicator. Touch events are ignored while the indicator is shown.

Note that the indicator will not show until the Lua code block containing the native.setActivityIndicator(true) call has completed execution. Also, if you try to show and hide the indicator within the same code block then the indicator will not show properly. Instead, call the code to hide the activity indicator in a separate function call or callback.

Your app won’t move forward until the texture is loaded.  Those calls block until they are done.  In other words:

show your loading screen

load an image

load another image

load some audio

hide your loading screen

should work as expected.  The hide won’t get called until the loads before it complete.

Rob

Great! Thanks Rob, esp for replying on Sunday!

Did you resolve this? Did you try native.setActivityIndicator?

From the documentation:

native.setActivityIndicator

Displays or hides a platform-specific activity indicator. Touch events are ignored while the indicator is shown.

Note that the indicator will not show until the Lua code block containing the native.setActivityIndicator(true) call has completed execution. Also, if you try to show and hide the indicator within the same code block then the indicator will not show properly. Instead, call the code to hide the activity indicator in a separate function call or callback.

Your app won’t move forward until the texture is loaded.  Those calls block until they are done.  In other words:

show your loading screen

load an image

load another image

load some audio

hide your loading screen

should work as expected.  The hide won’t get called until the loads before it complete.

Rob

Great! Thanks Rob, esp for replying on Sunday!