You don't, the asset is the TextureAtlas
, not the individual TextureRegions
.
This means that you let the AssetManager
load the TextureAtlas
and you manage getting the regions out of it yourself.
One way of doing this is the way Andreas Ohelke does it in Learning libGDX Development where a Assets
class load the TextureAtlas
and then simple wrapper classes are responsible for getting the regions in an easy to access format:
public class Assets {
private static final AssetDescriptor<TextureAtlas> SPRITE_ATLAS = new AssetDescriptor<TextureAtlas>("graphics/sprites.atlas", TextureAtlas.class);
public SpriteAssets sprites;
public void init(AssetManager assetManager) {
TextureAtlas spriteAtlas = assetManager.load(SPRITE_ATLAS, TextureAtlas.class);
assetManager.finishLoading();
sprites = new SpriteAssets(assetManager.get(SPRITE_ATLAS));
}
public class SpriteAssets {
public final TextureRegion ship;
public final TextureRegion player;
public final TextureRegion enemy;
public SpriteAssets(TextureAtlas atlas) {
ship = atlas.findRegion("ship");
player = atlas.findRegion("player");
enemy = atlas.findRegion("enemy");
}
}
}
(full example)