Android Question libGDX: Assetmanager with ScreenManager

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Does anyone have a short example of using the AssetManager to async load resources for an application that is also using a screen manager to handle multiple screens?

Per the AssetManager example program, in the main "LG_Create" block I initialize the screen manager and create a couple of screens, then I initialize and queue up the AssetManager.

In the LG_Render block I Return immediately if the AssetManager .Update method returns true.

In my screen _Show() blocks I create objects using assets, which throws an error indicating that the assets have not been loaded yet.

I have not been able to figure out how prevent the screen manager from invoking the show method before the async load finishes, so obviously I'm doing something wrong, or in the incorrect order.

Any suggestions would be most welcome.
 

Informatix

Expert
Licensed User
Longtime User
After reviewing my code, there was no bug in the screen events but the way they work was not ideal and not what we expect intuitively in such a case (the screen events were supposed to be an added layer over the standard events). And as you saw, I completely forgot that worked this way and thought also it was a bug, so I prefered to change that. Now the screen events replace Resize, Pause, Resume and Render. They do not replace Create and Dispose (to ensure that these events will always be fired at the beginning and the end of an application).
The new library is here.
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Outstanding! I'll try it first thing this morning. Hopefully, if I can ever get this template working I can start the actual project!

Thanks again for all your time and effort in making this outstanding library!

- Richard
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Your changes seem to work perfectly, thanks again!

For anyone who's been following or is interested, here is the sample project (cleaned up a bit) that uses the AssetManager to load some assets then allows you to switch between two different screens.
 

Attachments

  • AssetAndScreenMgr.zip
    200.3 KB · Views: 357
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…