Search in sources :

Example 1 with TextureAtlas

use of gaiasky.util.gdx.g2d.TextureAtlas in project gaiasky by langurmonkey.

the class BitmapFontLoader method loadSync.

@Override
public BitmapFont loadSync(AssetManager manager, String fileName, FileHandle file, BitmapFontParameter parameter) {
    if (parameter != null && parameter.atlasName != null) {
        TextureAtlas atlas = manager.get(parameter.atlasName, TextureAtlas.class);
        String name = file.sibling(data.imagePaths[0]).nameWithoutExtension();
        AtlasRegion region = atlas.findRegion(name);
        if (region == null)
            throw new GdxRuntimeException("Could not find font region " + name + " in atlas " + parameter.atlasName);
        return new BitmapFont(file, region);
    } else {
        int n = data.getImagePaths().length;
        Array<TextureRegion> regs = new Array(n);
        for (int i = 0; i < n; i++) {
            regs.add(new TextureRegion(manager.get(data.getImagePath(i), Texture.class)));
        }
        return new BitmapFont(data, regs, true);
    }
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) Array(com.badlogic.gdx.utils.Array) TextureRegion(gaiasky.util.gdx.g2d.TextureRegion) TextureAtlas(gaiasky.util.gdx.g2d.TextureAtlas) AtlasRegion(gaiasky.util.gdx.g2d.TextureAtlas.AtlasRegion) BitmapFont(gaiasky.util.gdx.g2d.BitmapFont)

Aggregations

Array (com.badlogic.gdx.utils.Array)1 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)1 BitmapFont (gaiasky.util.gdx.g2d.BitmapFont)1 TextureAtlas (gaiasky.util.gdx.g2d.TextureAtlas)1 AtlasRegion (gaiasky.util.gdx.g2d.TextureAtlas.AtlasRegion)1 TextureRegion (gaiasky.util.gdx.g2d.TextureRegion)1