Search in sources :

Example 1 with InternalFileHandleResolver

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

the class APKExpansionTest method create.

@Override
public void create() {
    if ((((AndroidFiles) Gdx.files)).setAPKExpansion(1, 0)) {
        resolver = new ZipFileHandleResolver();
    } else {
        Gdx.app.error("libgdx", "No Expansion can be opened");
    }
    assetManager = new AssetManager();
    FileHandleResolver resolver = new InternalFileHandleResolver();
    assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    assetManager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
    loadFont(assetManager, "data/DroidSerif-Regular.ttf", 12);
    loadFont(assetManager, "data/" + extensionPrefix + "DroidSerif-Regular.ttf", 12);
    assetManager.load("data/" + extensionPrefix + "testpackobb", TextureAtlas.class);
    assetManager.finishLoading();
    sound = Gdx.audio.newSound(Gdx.files.internal("data/" + extensionPrefix + "chirp.ogg"));
    sound.play();
    texture = new Texture(resolver.resolve("data/" + extensionPrefix + "badlogic.jpg"));
    batch = new SpriteBatch();
    TextureAtlas atlas = assetManager.get("data/" + extensionPrefix + "testpackobb");
    atlasTextureRegion = new TextureRegion(atlas.findRegion("water"));
    sound = Gdx.audio.newSound(Gdx.files.internal("data/shotgun.ogg"));
    sound.play();
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) FileHandleResolver(com.badlogic.gdx.assets.loaders.FileHandleResolver) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) FreeTypeFontGeneratorLoader(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader) FreetypeFontLoader(com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 2 with InternalFileHandleResolver

use of com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver 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 3 with InternalFileHandleResolver

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

the class TiledMapLayerOffsetTest method create.

@Override
public void create() {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, (w / h) * 10, 10);
    camera.zoom = 2;
    camera.update();
    cameraController = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(cameraController);
    font = new BitmapFont();
    batch = new SpriteBatch();
    shapeRenderer = new ShapeRenderer();
    assetManager = new AssetManager();
    assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
    assetManager.load(MAP_ORTHO, TiledMap.class);
    assetManager.load(MAP_ISO, TiledMap.class);
    assetManager.load(MAP_ISO_STAG, TiledMap.class);
    assetManager.load(MAP_HEX_X, TiledMap.class);
    assetManager.load(MAP_HEX_Y, TiledMap.class);
    assetManager.finishLoading();
    map = assetManager.get(MAP_ORTHO);
    renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
Also used : OrthogonalTiledMapRenderer(com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer) TmxMapLoader(com.badlogic.gdx.maps.tiled.TmxMapLoader) AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 4 with InternalFileHandleResolver

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

the class TideMapAssetManagerTest method create.

@Override
public void create() {
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, (w / h) * 10, 10);
    camera.zoom = 2;
    camera.update();
    cameraController = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(cameraController);
    font = new BitmapFont();
    batch = new SpriteBatch();
    assetManager = new AssetManager();
    assetManager.setLoader(TiledMap.class, new TideMapLoader(new InternalFileHandleResolver()));
    assetManager.load("data/maps/tide/Map01.tide", TiledMap.class);
    assetManager.finishLoading();
    map = assetManager.get("data/maps/tide/Map01.tide");
    renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f);
}
Also used : OrthogonalTiledMapRenderer(com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer) AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) TideMapLoader(com.badlogic.gdx.maps.tiled.TideMapLoader) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 5 with InternalFileHandleResolver

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

the class FreeTypeFontLoaderTest method create.

@Override
public void create() {
    manager = new AssetManager();
    // set the loaders for the generator and the fonts themselves
    FileHandleResolver resolver = new InternalFileHandleResolver();
    manager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
    // load to fonts via the generator (implicitely done by the FreetypeFontLoader).
    // Note: you MUST specify a FreetypeFontGenerator defining the ttf font file name and the size
    // of the font to be generated. The names of the fonts are arbitrary and are not pointing
    // to a file on disk!
    FreeTypeFontLoaderParameter size1Params = new FreeTypeFontLoaderParameter();
    size1Params.fontFileName = "data/arial.ttf";
    size1Params.fontParameters.size = 10;
    manager.load("size10.ttf", BitmapFont.class, size1Params);
    FreeTypeFontLoaderParameter size2Params = new FreeTypeFontLoaderParameter();
    size2Params.fontFileName = "data/arial.ttf";
    size2Params.fontParameters.size = 20;
    manager.load("size20.ttf", BitmapFont.class, size2Params);
    // we also load a "normal" font generated via Hiero
    manager.load("data/default.fnt", BitmapFont.class);
    batch = new SpriteBatch();
}
Also used : FreeTypeFontLoaderParameter(com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader.FreeTypeFontLoaderParameter) AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) FileHandleResolver(com.badlogic.gdx.assets.loaders.FileHandleResolver) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) FreeTypeFontGeneratorLoader(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader) FreetypeFontLoader(com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Aggregations

InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)10 AssetManager (com.badlogic.gdx.assets.AssetManager)8 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)8 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)5 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)5 OrthoCamController (com.badlogic.gdx.tests.utils.OrthoCamController)4 FileHandleResolver (com.badlogic.gdx.assets.loaders.FileHandleResolver)3 FreeTypeFontGeneratorLoader (com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader)3 FreetypeFontLoader (com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader)3 OrthogonalTiledMapRenderer (com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer)3 AtlasTmxMapLoader (com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader)2 TmxMapLoader (com.badlogic.gdx.maps.tiled.TmxMapLoader)2 AssetDescriptor (com.badlogic.gdx.assets.AssetDescriptor)1 AssetErrorListener (com.badlogic.gdx.assets.AssetErrorListener)1 TextureLoader (com.badlogic.gdx.assets.loaders.TextureLoader)1 ResolutionFileResolver (com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver)1 Resolution (com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution)1 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 Texture (com.badlogic.gdx.graphics.Texture)1 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)1