Package com.badlogic.gdx.graphics.g2d.TextureAtlas

Examples of com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion


    return super.wrap(object);
  }

  public Actor newWidget (TableLayout layout, String className) {
    if (layout.atlas != null) {
      AtlasRegion region = layout.atlas.findRegion(className);
      if (region != null) return new Image(className, region);
    }
    return super.newWidget(layout, className);
  }
View Full Code Here


    float localX2 = width / 2;
    float localY2 = height / 2;
    float localX = -localX2;
    float localY = -localY2;
    if (region instanceof AtlasRegion) {
      AtlasRegion region = (AtlasRegion)this.region;
      if (region.rotate) {
        localX += region.offsetX / region.originalWidth * height;
        localY += region.offsetY / region.originalHeight * width;
        localX2 -= (region.originalWidth - region.offsetX - region.packedHeight) / region.originalWidth * height;
        localY2 -= (region.originalHeight - region.offsetY - region.packedWidth) / region.originalHeight * width;
 
View Full Code Here

    // A regular texture atlas would normally usually be used. This returns a white image for images not found in the atlas.
    Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    final AtlasRegion fake = new AtlasRegion(new Texture(pixmap), 0, 0, 32, 32);
    pixmap.dispose();
    FileHandle atlasFile = Gdx.files.internal(name + ".atlas");
    TextureAtlasData data = !atlasFile.exists() ? null : new TextureAtlasData(atlasFile, atlasFile.parent(), false);
    TextureAtlas atlas = new TextureAtlas(data) {
      public AtlasRegion findRegion (String name) {
        AtlasRegion region = super.findRegion(name);
        return region != null ? region : fake;
      }
    };

    if (true) {
View Full Code Here

    default:
      throw new IllegalArgumentException("Unknown attachment type: " + type);
    }

    if (attachment instanceof RegionAttachment) {
      AtlasRegion region = atlas.findRegion(attachment.getName());
      if (region == null)
        throw new RuntimeException("Region not found in atlas: " + attachment + " (" + type + " attachment: " + name + ")");
      ((RegionAttachment)attachment).setRegion(region);
    }
View Full Code Here

        float v = region.v;
        float regionWidth = region.getRegionWidth();
        float regionHeight = region.getRegionHeight();
        if (region instanceof AtlasRegion) {
          // Compensate for whitespace stripped from left and top edges.
          AtlasRegion atlasRegion = (AtlasRegion)region;
          offsetX = atlasRegion.offsetX;
          offsetY = atlasRegion.originalHeight - atlasRegion.packedHeight - atlasRegion.offsetY;
        }
       
       
View Full Code Here

  /** Adds all named txeture regions from the atlas. The atlas will not be automatically disposed when the skin is disposed. */
  public void addRegions (TextureAtlas atlas) {
    Array<AtlasRegion> regions = atlas.getRegions();
    for (int i = 0, n = regions.size; i < n; i++) {
      AtlasRegion region = regions.get(i);
      add(region.name, region, TextureRegion.class);
    }
  }
View Full Code Here

    if (sprite != null) return sprite;

    try {
      TextureRegion textureRegion = getRegion(name);
      if (textureRegion instanceof AtlasRegion) {
        AtlasRegion region = (AtlasRegion)textureRegion;
        if (region.rotate || region.packedWidth != region.originalWidth || region.packedHeight != region.originalHeight)
          sprite = new AtlasSprite(region);
      }
      if (sprite == null) sprite = new Sprite(textureRegion);
      add(name, sprite, NinePatch.class);
View Full Code Here

    // Use texture or texture region. If it has splits, use ninepatch. If it has rotation or whitespace stripping, use sprite.
    try {
      TextureRegion textureRegion = getRegion(name);
      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));
      }
View Full Code Here

          Element imageElement = tileElement.getChildByName("image");
          if (imageElement != null) {
            // Is a tilemap with individual images.
            String regionName = imageElement.getAttribute("source");
            regionName = regionName.substring(0, regionName.lastIndexOf('.'));
            AtlasRegion region = atlas.findRegion(regionName);
            if (region == null) throw new GdxRuntimeException("Tileset region not found: " + regionName);
            tile = new StaticTiledMapTile(region);
            tile.setId(tileid);
            tile.setOffsetX(offsetX);
            tile.setOffsetY(-offsetY);
View Full Code Here

        float v = region.v;
        float regionWidth = region.getRegionWidth();
        float regionHeight = region.getRegionHeight();
        if (region instanceof AtlasRegion) {
          // Compensate for whitespace stripped from left and top edges.
          AtlasRegion atlasRegion = (AtlasRegion)region;
          offsetX = atlasRegion.offsetX;
          offsetY = atlasRegion.originalHeight - atlasRegion.packedHeight - atlasRegion.offsetY;
        }

        float x = glyph.srcX;
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion

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.