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);
}
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()]);
}
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;
}
}
}
Aggregations