1
\$\begingroup\$

I am a beginner in libgdx and I am coding a simple game. This game is like a word puzzle where each letter is a texture. Before loading the first level I need to load into memory 26 textures, one for each alphabet letter, and also an English dictionary stored in memory as a .txt file. The problem is that my dictionary needs to be processed and loaded into memory (complexity Big-O is O(n) where n is around 200k). Where should I process it? Inside the asset manager class or in the class where it will actually be used?

Also, different levels may use the exact same textures so it would be great to load them in memory only once rather than disposing them every time a level ends. Is storing them in a static variable in the Assetmanager class a nice solution to this problem?

\$\endgroup\$
1
\$\begingroup\$

About textures loading, yes i suggest you to make them static in the AssetManager class and then declaring them in the "level" class with Texture letterA = AssetManager.letterA and so on.

Same goes for the dictionary (i never had to process a .txt file so i don't know if you're going to declare it as a String or else..).

I usually make static every asset that is not going to be modified, and use it in other classes like i wrote.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .