Loading all textures from a folder
When creating a game that has a large amount of textures, loading each texture individually can become tedious. Creating a method to load and retrieve textures in such a game can be not only timesaving during development, but also reduce the overall loading times during runtime. In this recipe, we will create a way to load a large amount of textures using only a single line of code.
Getting ready...
First, create a new activity class named TextureFolderLoadingActivity
that extends the BaseGameActivity
class. Next, create a folder named FolderToLoad
in the assets/gfx/
folder. Finally, place five images in the assets/gfx/FolderToLoad/
folder with the names: Coin1
, Coin5
, Coin10
, Coin50
, and Coin100
.
How to do it...
Follow these steps to fill our TextureFolderLoadingActivity
activity class:
Place the following, simple code in our activity to make it functional:
@Override public EngineOptions onCreateEngineOptions() { return new EngineOptions(true, ScreenOrientation...