Search in sources :

Example 21 with TextureAtlas

use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.

the class YDownTest method create.

@Override
public void create() {
    // a bitmap font to draw some text, note that we
    // pass true to the constructor, which flips glyphs on y
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), true);
    // a texture region, note the flipping on y again
    region = new TextureRegion(new Texture("data/badlogic.jpg"));
    region.flip(false, true);
    // a texture atlas, note the boolean
    atlas = new TextureAtlas(Gdx.files.internal("data/pack"), true);
    // a sprite, created from a region in the atlas
    sprite = atlas.createSprite("badlogicsmall");
    sprite.setPosition(0, 0);
    // a sprite batch with which we want to render
    batch = new SpriteBatch();
    // a camera, note the setToOrtho call, which will set the y-axis
    // to point downwards
    camera = new OrthographicCamera();
    camera.setToOrtho(true);
    // a stage which uses our y-down camera and a simple actor (see MyActor below),
    // which uses the flipped region. The key here is to
    // set our y-down camera on the stage, the rest is just for demo purposes.
    stage = new Stage();
    stage.getViewport().setCamera(camera);
    image = new MyActor(region);
    image.setPosition(100, 100);
    stage.addActor(image);
    // finally we write up the stage as the input process and call it a day.
    Gdx.input.setInputProcessor(stage);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) Stage(com.badlogic.gdx.scenes.scene2d.Stage) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 22 with TextureAtlas

use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.

the class FreeTypeMetricsTest method create.

@Override
public void create() {
    spriteBatch = new SpriteBatch();
    atlas = new TextureAtlas("data/pack");
    smallFont = new BitmapFont();
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = 60;
    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf"));
    font = generator.generateFont(parameter);
    generator.dispose();
    renderer = new ShapeRenderer();
    renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
}
Also used : FreeTypeFontGenerator(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator) FreeTypeFontParameter(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 23 with TextureAtlas

use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.

the class ParticleEffectLoader method getDependencies.

@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, ParticleEffectParameter param) {
    Array<AssetDescriptor> deps = null;
    if (param != null && param.atlasFile != null) {
        deps = new Array();
        deps.add(new AssetDescriptor<TextureAtlas>(param.atlasFile, TextureAtlas.class));
    }
    return deps;
}
Also used : Array(com.badlogic.gdx.utils.Array) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) AssetDescriptor(com.badlogic.gdx.assets.AssetDescriptor)

Example 24 with TextureAtlas

use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.

the class SkinLoader method loadSync.

@Override
public Skin loadSync(AssetManager manager, String fileName, FileHandle file, SkinParameter parameter) {
    String textureAtlasPath = file.pathWithoutExtension() + ".atlas";
    ObjectMap<String, Object> resources = null;
    if (parameter != null) {
        if (parameter.textureAtlasPath != null) {
            textureAtlasPath = parameter.textureAtlasPath;
        }
        if (parameter.resources != null) {
            resources = parameter.resources;
        }
    }
    TextureAtlas atlas = manager.get(textureAtlasPath, TextureAtlas.class);
    Skin skin = new Skin(atlas);
    if (resources != null) {
        for (Entry<String, Object> entry : resources.entries()) {
            skin.add(entry.key, entry.value);
        }
    }
    skin.load(file);
    return skin;
}
Also used : TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin)

Example 25 with TextureAtlas

use of com.badlogic.gdx.graphics.g2d.TextureAtlas in project libgdx by libgdx.

the class TextureAtlasLoader method load.

@Override
public TextureAtlas load(AssetManager assetManager, String fileName, FileHandle file, TextureAtlasParameter parameter) {
    for (Page page : data.getPages()) {
        Texture texture = assetManager.get(page.textureFile.path().replaceAll("\\\\", "/"), Texture.class);
        page.texture = texture;
    }
    return new TextureAtlas(data);
}
Also used : TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) Page(com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Page) Texture(com.badlogic.gdx.graphics.Texture)

Aggregations

TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)33 Texture (com.badlogic.gdx.graphics.Texture)11 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)11 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)10 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)7 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)6 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)6 FileHandle (com.badlogic.gdx.files.FileHandle)5 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)4 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)4 Array (com.badlogic.gdx.utils.Array)4 Animation (com.badlogic.gdx.graphics.g2d.Animation)3 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)3 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)3 TexturePacker (com.badlogic.gdx.tools.texturepacker.TexturePacker)3 InputAdapter (com.badlogic.gdx.InputAdapter)2 Pixmap (com.badlogic.gdx.graphics.Pixmap)2 Page (com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Page)2 ShaderProgram (com.badlogic.gdx.graphics.glutils.ShaderProgram)2 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)2