0
\$\begingroup\$

I've put my libGDX view inside a bigger Android layout. When the user rotates the screen, a new layout specific for the orientation is drawn, for this reason, the activity is rebuilt from scratch forcing the libGDX view to reload all assets.

I tried to store these assets in a static variable, but on the second time I create the libGDX view, they are not rendered correctly (it looks like textures are not loaded and everything is transparent).

How can I avoid reloading heavy assets (models and textures)?

\$\endgroup\$
  • \$\begingroup\$ Are you sure the assets are indeed reloading? I've done some android development in the past, and when the screen is rotated, programming-wise you have to "re-load" the assets, but in reality, behind the scenes, android caches them and is able to reload them instantly. The only exception being if it doesn't have enough memory to do so, in which case there's nothing you can do on your side. \$\endgroup\$ – TomTsagk Sep 13 '19 at 15:03
0
\$\begingroup\$

i haven't seen much that implementation, usually you have to create your assets every time you enter a new level, and dispose all of them if you change of level/screen, when libgdx reload all assets at the same time is freeing memory of other assets, to implement what you want is more an issue of game design, i mean, if you know there will be the same background in several levels, then you have to load that asset once and have in memory or not to dispose it under specific circunstances.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ And how would they store the assets in memory? That's what they tried and they had issues with there technique. \$\endgroup\$ – Vaillancourt Apr 16 '19 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.