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\$
1
  • \$\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\$ Commented Sep 13, 2019 at 15:03

1 Answer 1

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.

\$\endgroup\$
1
  • \$\begingroup\$ And how would they store the assets in memory? That's what they tried and they had issues with their technique. \$\endgroup\$ Commented Apr 16, 2019 at 13:18

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.