Java 类com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution 实例源码

项目:bladecoder-adventure-engine    文件:EngineResolutionFileResolver.java   
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;
        }
    }
}
项目:gdxjam-ugg    文件:GUIConfig.java   
public static void initializeValues(Resolution[] resolutions){
    Resolution r = ResolutionFileResolver.choose(resolutions);

    float multiplier = 1;

    if(r.folder.equals("1")){
        multiplier = 0.80f;
        RES_MULTIPLIER = 6f;
    }else if(r.folder.equals("0.66")){
        multiplier = 0.60f;
        RES_MULTIPLIER = 4f;
    }else if(r.folder.equals("0.416")){
        multiplier = 0.400f;
        RES_MULTIPLIER = 2.5f;
    }else{
        multiplier = 0.16f;
        RES_MULTIPLIER = 1f;
    }

    MINPADDING = (int)(MINPADDING*multiplier);
    WINDOW_PADDING_Y = (int)(WINDOW_PADDING_Y*multiplier);
    WINDOW_PADDING_X = (int)(WINDOW_PADDING_X*multiplier);

    MIN_BUTTON_HEIGHT = (int)(MIN_BUTTON_HEIGHT * multiplier);
    MIN_BTN_WIDTH = (int)(MIN_BTN_WIDTH * multiplier);
    SLIDER_WIDTH = (int)(SLIDER_WIDTH * multiplier);

    PIXELS_PER_METER_X = (int)(PIXELS_PER_METER_X*multiplier);

    MIN_BTN_SELECT_WIDTH = (int)(MIN_BTN_SELECT_WIDTH*multiplier);
}
项目:libgdxcn    文件:AssetManagerTest.java   
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);
}
项目:bladecoder-adventure-engine    文件:EngineAssetManager.java   
public void setScale(int worldWidth, int worldHeight) {
    Resolution r[] = getResolutions(resResolver.getBaseResolver(), worldWidth, worldHeight);

    if (r == null || r.length == 0) {
        EngineLogger.error("No resolutions defined. Maybe your 'assets' folder doesn't exists or it's empty");
        return;
    }

    resResolver.setResolutions(r);
    resResolver.selectResolution();
    scale = resResolver.getResolution().portraitWidth / (float) worldWidth;

    EngineLogger.debug("Setting ASSETS SCALE: " + scale);
}
项目:bladecoder-adventure-engine    文件:EngineAssetManager.java   
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()]);
}
项目:bladecoder-adventure-engine    文件:EngineResolutionFileResolver.java   
public Resolution[] getResolutions() {
    return descriptors;
}
项目:bladecoder-adventure-engine    文件:EngineResolutionFileResolver.java   
public Resolution getResolution() {
    return bestDesc;
}
项目:bladecoder-adventure-engine    文件:EngineResolutionFileResolver.java   
public void setResolutions(Resolution[] resolutions) {
    this.descriptors = resolutions;
}
项目:bladecoder-adventure-engine    文件:EngineAssetManager.java   
public Resolution getResolution() {
    return resResolver.getResolution();
}