Package com.badlogic.gdx.scenes.scene2d.utils

Examples of com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable


      if (textureRegion instanceof AtlasRegion) {
        AtlasRegion region = (AtlasRegion)textureRegion;
        if (region.splits != null)
          drawable = new NinePatchDrawable(getPatch(name));
        else if (region.rotate || region.packedWidth != region.originalWidth || region.packedHeight != region.originalHeight)
          drawable = new SpriteDrawable(getSprite(name));
      }
      if (drawable == null) drawable = new TextureRegionDrawable(textureRegion);
    } catch (GdxRuntimeException ignored) {
    }

    // Check for explicit registration of ninepatch, sprite, or tiled drawable.
    if (drawable == null) {
      NinePatch patch = optional(name, NinePatch.class);
      if (patch != null)
        drawable = new NinePatchDrawable(patch);
      else {
        Sprite sprite = optional(name, Sprite.class);
        if (sprite != null)
          drawable = new SpriteDrawable(sprite);
        else
          throw new GdxRuntimeException("No Drawable, NinePatch, TextureRegion, Texture, or Sprite registered with name: "
            + name);
      }
    }
View Full Code Here


  /** Returns a copy of the specified drawable. */
  public Drawable newDrawable (Drawable drawable) {
    if (drawable instanceof TextureRegionDrawable) return new TextureRegionDrawable((TextureRegionDrawable)drawable);
    if (drawable instanceof NinePatchDrawable) return new NinePatchDrawable((NinePatchDrawable)drawable);
    if (drawable instanceof SpriteDrawable) return new SpriteDrawable((SpriteDrawable)drawable);
    throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass());
  }
View Full Code Here

      if (region instanceof AtlasRegion)
        sprite = new AtlasSprite((AtlasRegion)region);
      else
        sprite = new Sprite(region);
      sprite.setColor(tint);
      return new SpriteDrawable(sprite);
    }
    if (drawable instanceof NinePatchDrawable) {
      NinePatchDrawable patchDrawable = new NinePatchDrawable((NinePatchDrawable)drawable);
      patchDrawable.setPatch(new NinePatch(patchDrawable.getPatch(), tint));
      return patchDrawable;
    }
    if (drawable instanceof SpriteDrawable) {
      SpriteDrawable spriteDrawable = new SpriteDrawable((SpriteDrawable)drawable);
      Sprite sprite = spriteDrawable.getSprite();
      if (sprite instanceof AtlasSprite)
        sprite = new AtlasSprite((AtlasSprite)sprite);
      else
        sprite = new Sprite(sprite);
      sprite.setColor(tint);
      spriteDrawable.setSprite(sprite);
      return spriteDrawable;
    }
    throw new GdxRuntimeException("Unable to copy, unknown drawable type: " + drawable.getClass());
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.