Search in sources :

Example 6 with InternalFileHandleResolver

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

the class TiledMapAssetManagerTest 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 TmxMapLoader(new InternalFileHandleResolver()));
    assetManager.load("data/maps/tiled/isometric_grass_and_water.tmx", TiledMap.class);
    assetManager.finishLoading();
    map = assetManager.get("data/maps/tiled/isometric_grass_and_water.tmx");
    renderer = new IsometricTiledMapRenderer(map, 1f / 64f);
    String mapCustomValue = map.getProperties().get(MAP_PROPERTY_NAME, String.class);
    Gdx.app.log("TiledMapAssetManagerTest", "Property : " + MAP_PROPERTY_NAME + ", Value : " + mapCustomValue);
    if (!MAP_PROPERTY_VALUE.equals(mapCustomValue)) {
        throw new RuntimeException("Failed to get map properties");
    }
    boolean boolCustomValue = map.getProperties().get(BOOL_PROPERTY_NAME, Boolean.class);
    Gdx.app.log("TiledMapAssetManagerTest", "Property : " + BOOL_PROPERTY_NAME + ", Value : " + boolCustomValue);
    if (boolCustomValue != BOOL_PROPERTY_VALUE) {
        throw new RuntimeException("Failed to get boolean map properties");
    }
    int intCustomValue = map.getProperties().get(INT_PROPERTY_NAME, Integer.class);
    Gdx.app.log("TiledMapAssetManagerTest", "Property : " + INT_PROPERTY_NAME + ", Value : " + intCustomValue);
    if (intCustomValue != INT_PROPERTY_VALUE) {
        throw new RuntimeException("Failed to get int map properties");
    }
    float floatCustomValue = map.getProperties().get(FLOAT_PROPERTY_NAME, Float.class);
    Gdx.app.log("TiledMapAssetManagerTest", "Property : " + FLOAT_PROPERTY_NAME + ", Value : " + floatCustomValue);
    if (floatCustomValue != FLOAT_PROPERTY_VALUE) {
        throw new RuntimeException("Failed to get float map properties");
    }
    TiledMapTileSet tileset = map.getTileSets().getTileSet(0);
    String tilesetCustomValue = tileset.getProperties().get(TILESET_PROPERTY_NAME, String.class);
    if (!TILESET_PROPERTY_VALUE.equals(tilesetCustomValue)) {
        throw new RuntimeException("Failed to get tileset properties");
    }
    TiledMapTile tile = tileset.getTile(1);
    String tileCustomValue = tile.getProperties().get(TILE_PROPERTY_NAME, String.class);
    if (!TILE_PROPERTY_VALUE.equals(tileCustomValue)) {
        throw new RuntimeException("Failed to get tile properties");
    }
    MapLayer layer = map.getLayers().get(0);
    String layerCustomValue = layer.getProperties().get(LAYER_PROPERTY_NAME, String.class);
    if (!LAYER_PROPERTY_VALUE.equals(layerCustomValue)) {
        throw new RuntimeException("Failed to get layer properties");
    }
}
Also used : TmxMapLoader(com.badlogic.gdx.maps.tiled.TmxMapLoader) AssetManager(com.badlogic.gdx.assets.AssetManager) TiledMapTileSet(com.badlogic.gdx.maps.tiled.TiledMapTileSet) MapLayer(com.badlogic.gdx.maps.MapLayer) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) IsometricTiledMapRenderer(com.badlogic.gdx.maps.tiled.renderers.IsometricTiledMapRenderer) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 7 with InternalFileHandleResolver

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

the class TiledMapAtlasAssetManagerTest 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();
    AtlasTiledMapLoaderParameters params = new AtlasTiledMapLoaderParameters();
    params.forceTextureFilters = true;
    params.textureMinFilter = TextureFilter.Linear;
    params.textureMagFilter = TextureFilter.Linear;
    assetManager = new AssetManager();
    assetManager.setErrorListener(new AssetErrorListener() {

        @Override
        public void error(AssetDescriptor asset, Throwable throwable) {
            errorMessage = throwable.getMessage();
        }
    });
    assetManager.setLoader(TiledMap.class, new AtlasTmxMapLoader(new InternalFileHandleResolver()));
    assetManager.load(fileName, TiledMap.class);
}
Also used : AtlasTiledMapLoaderParameters(com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters) AssetManager(com.badlogic.gdx.assets.AssetManager) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) AssetErrorListener(com.badlogic.gdx.assets.AssetErrorListener) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) AtlasTmxMapLoader(com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 8 with InternalFileHandleResolver

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

the class TiledMapPackerTestRender method create.

@Override
public void create() {
    atlasTmxMapLoader = new AtlasTmxMapLoader(new InternalFileHandleResolver());
    params = new AtlasTmxMapLoader.AtlasTiledMapLoaderParameters();
    params.generateMipMaps = false;
    params.convertObjectToTileSpace = false;
    params.flipY = true;
    viewport = new FitViewport(WORLD_WIDTH, WORLD_HEIGHT);
    cam = (OrthographicCamera) viewport.getCamera();
    map = atlasTmxMapLoader.load(TMX_LOC, params);
    mapRenderer = new OrthogonalTiledMapRenderer(map, UNIT_SCALE);
}
Also used : OrthogonalTiledMapRenderer(com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) AtlasTmxMapLoader(com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader) FitViewport(com.badlogic.gdx.utils.viewport.FitViewport)

Example 9 with InternalFileHandleResolver

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

the class RubeLoaderTest method initiateSceneLoad.

/**
    * Kicks off asset manager if selected... 
    * 
    */
private void initiateSceneLoad() {
    if (mUseAssetManager) {
        // kick off asset manager operations...
        mAssetManager = new AssetManager();
        mAssetManager.setLoader(RubeScene.class, new RubeSceneAsyncLoader(new InternalFileHandleResolver()));
        // kick things off..
        mAssetManager.load(RUBE_SCENE_FILE_LIST[mRubeFileList][mRubeFileIndex], RubeScene.class);
    }
    mNextState = GAME_STATE.LOADING;
}
Also used : AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) RubeSceneAsyncLoader(com.gushikustudios.rube.loader.RubeSceneAsyncLoader)

Aggregations

InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)9 AssetManager (com.badlogic.gdx.assets.AssetManager)8 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)7 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)5 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)4 OrthoCamController (com.badlogic.gdx.tests.utils.OrthoCamController)4 OrthogonalTiledMapRenderer (com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer)3 FileHandleResolver (com.badlogic.gdx.assets.loaders.FileHandleResolver)2 FreeTypeFontGeneratorLoader (com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader)2 FreetypeFontLoader (com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader)2 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 Texture (com.badlogic.gdx.graphics.Texture)1 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1