Managing resources
In many games written in AndEngine, you will see the ResourceManager
class. It's one of the established patterns that you should be using as well. ResourceManager
is simply a class that takes care of loading and unloading of the resources. Because the memory in Android devices is very limited, it is important to have a centralized point that will ensure each asset is loaded only once and made available throughout the entire game code. When working with limited space, you can also consider unloading resources that are not being currently used.
Note
When you suspend a game by pressing the Home button or when another activity takes over, for example, when receiving a call, resources might be unloaded automatically. AndEngine makes them available again when the control is returned to the game.
The ResourceManager
class is usually designed as a singleton. That is another design pattern. It ensures that only one instance of the class is created during the entire run of the...