The Loading Screen
You could find a better formatted version of this devlog at this link
A fundamental use case of the asset manager is in the LoadingScreen. With this tecnique you can load all assets within a directory while showing progress.
public class LoadingScreen extends SpaceFloatScreen { private static final String TEXTURE_DIRECTORY = "textures/"; private AssetManager assetManager; private float progress; @Override public void show() { super.show(); assetManager = getAssetManager(); FileHandle[] files = Gdx.files.local(TEXTURE_DIRECTORY).list(); for(FileHandle file : files) { assetManager.load(file.path(), Texture.class); } } @Override public void render(float delta) { assetManager.update(); progress = assetManager.getProgress(); logger.info("Loading assets: " + progress); if (progress < 1.0f) return; SpaceFloat.GAME.setScreen(ScreenEnumerator.MAIN); } }
I'm also glad to show you the new cargoship which you drive in SpaceFloat!