Example usage for com.badlogic.gdx.rube.graphics.g2d RubeSprite RubeSprite

List of usage examples for com.badlogic.gdx.rube.graphics.g2d RubeSprite RubeSprite

Introduction

In this page you can find the example usage for com.badlogic.gdx.rube.graphics.g2d RubeSprite RubeSprite.

Prototype

public RubeSprite(TextureRegion region, RubeImage imageData) 

Source Link

Document

Creates a RubeSprite and setup it with the information in the RubeImage .

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;//from   w w w  . j  a  v a2  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);
    }
}