Search in sources :

Example 1 with Resolution

use of com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution in project libgdx by libgdx.

the class AssetManagerTest method create.

public void create() {
    Gdx.app.setLogLevel(Application.LOG_ERROR);
    Resolution[] resolutions = { new Resolution(320, 480, ".320480"), new Resolution(480, 800, ".480800"), new Resolution(480, 856, ".480854") };
    ResolutionFileResolver resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), resolutions);
    manager = new AssetManager();
    manager.setLoader(Texture.class, new TextureLoader(resolver));
    manager.setErrorListener(this);
    load();
    Texture.setAssetManager(manager);
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), false);
}
Also used : ResolutionFileResolver(com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver) AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) TextureLoader(com.badlogic.gdx.assets.loaders.TextureLoader) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Resolution(com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution)

Example 2 with Resolution

use of com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution in project bladecoder-adventure-engine by bladecoder.

the class EngineAssetManager method getResolutions.

private Resolution[] getResolutions(FileHandleResolver resolver, int worldWidth, int worldHeight) {
    ArrayList<Resolution> rl = new ArrayList<Resolution>();
    String[] list = null;
    String configRes = Config.getProperty(Config.RESOLUTIONS, null);
    if (configRes != null) {
        list = configRes.split(",");
    } else {
        list = listAssetFiles("ui");
    }
    for (String name : list) {
        try {
            float scale = Float.parseFloat(name);
            EngineLogger.debug("RES FOUND: " + scale);
            Resolution r = new Resolution((int) (worldWidth * scale), (int) (worldHeight * scale), name);
            rl.add(r);
        } catch (NumberFormatException e) {
        }
    }
    Collections.sort(rl, new Comparator<Resolution>() {

        public int compare(Resolution a, Resolution b) {
            return a.portraitWidth - b.portraitWidth;
        }
    });
    return rl.toArray(new Resolution[rl.size()]);
}
Also used : ArrayList(java.util.ArrayList) Resolution(com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution)

Example 3 with Resolution

use of com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution in project bladecoder-adventure-engine by bladecoder.

the class EngineResolutionFileResolver method selectBestResolution.

private void selectBestResolution() {
    bestDesc = descriptors[0];
    int width = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? Gdx.graphics.getWidth() : Gdx.graphics.getHeight();
    int bestDist = Math.abs(width - bestDesc.portraitWidth);
    for (int i = 1; i < descriptors.length; i++) {
        Resolution other = descriptors[i];
        int dist = Math.abs(width - other.portraitWidth);
        if (dist < bestDist) {
            bestDesc = descriptors[i];
            bestDist = dist;
        }
    }
}
Also used : Resolution(com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution)

Aggregations

Resolution (com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution)3 AssetManager (com.badlogic.gdx.assets.AssetManager)1 TextureLoader (com.badlogic.gdx.assets.loaders.TextureLoader)1 InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)1 ResolutionFileResolver (com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver)1 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 ArrayList (java.util.ArrayList)1