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

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

Introduction

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

Prototype

public boolean usesAtlas() 

Source Link

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;//w w w . ja v a2s.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);
    }
}