Example usage for com.badlogic.gdx.rube RubeScene getAtlasFilePath

List of usage examples for com.badlogic.gdx.rube RubeScene getAtlasFilePath

Introduction

In this page you can find the example usage for com.badlogic.gdx.rube RubeScene getAtlasFilePath.

Prototype

public String getAtlasFilePath(int index) 

Source Link

Document

Returns the path + filename of the atlas to use.

Usage

From source file:com.badlogic.gdx.rube.test.SpriteRenderer.java

public void addImage(RubeScene _scene, RubeImage _image, AssetManager assetManager) {

    if (_image instanceof RubeImage) {
        RubeImage image = (RubeImage) _image;

        Texture texture = null;/*  ww  w.  j  a v  a 2  s  .c o  m*/
        RubeSprite sprite = null;

        if (assetManager != null) {
            // If the scene uses atlases instead of a bunch of texture we get it instead
            if (_scene.usesAtlas()) {
                TextureAtlas atlas = assetManager.get("data/" + _scene.getAtlasFilePath(0), TextureAtlas.class);
                if (atlas != null) {
                    TextureRegion region = atlas.findRegion(image.file);
                    if (region != null)
                        sprite = new RubeSprite(region, image);
                }
            } else // else we get the textures
            {
                texture = assetManager.get("data/" + image.file, Texture.class);
                sprite = new RubeSprite(texture, image);
            }
        } else // If we don't use the asset manager we create a texture if needed
        {
            texture = textureMap.get("data/" + image.file);
            if (texture == null) {
                texture = new Texture("data/" + image.file);
                textureMap.put("data/" + image.file, texture);
            }
            sprite = new RubeSprite(texture, image);
        }

        if (sprite != null)
            sprites.add(sprite);
    }
}