Examples of AtlasRegion


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

          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

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

        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

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

    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 * width;
        localY += region.offsetY / region.originalHeight * height;
        localX2 -= (region.originalWidth - region.offsetX - region.packedHeight) / region.originalWidth * width;
        localY2 -= (region.originalHeight - region.offsetY - region.packedWidth) / region.originalHeight * height;
 
View Full Code Here

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

    // This loader creates Box2dAttachments instead of RegionAttachments for an easy way to keep
    // track of the Box2D body for each attachment.
    AtlasAttachmentLoader atlasLoader = new AtlasAttachmentLoader(atlas) {
      public RegionAttachment newRegionAttachment (Skin skin, String name, String path) {
        Box2dAttachment attachment = new Box2dAttachment(name);
        AtlasRegion region = atlas.findRegion(attachment.getName());
        if (region == null) throw new RuntimeException("Region not found in atlas: " + attachment);
        attachment.setRegion(region);
        return attachment;
      }
    };
View Full Code Here

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

    // 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(new Color(1, 1, 1, 0.33f));
    pixmap.fill();
    final AtlasRegion fake = new AtlasRegion(new Texture(pixmap), 0, 0, 32, 32);
    pixmap.dispose();

    String atlasFileName = skeletonFile.nameWithoutExtension();
    if (atlasFileName.endsWith(".json")) atlasFileName = new FileHandle(atlasFileName).nameWithoutExtension();
    FileHandle atlasFile = skeletonFile.sibling(atlasFileName + ".atlas");
    if (!atlasFile.exists()) atlasFile = skeletonFile.sibling(atlasFileName + ".atlas.txt");
    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;
      }
    };

    try {
View Full Code Here

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

    if (atlas == null) throw new IllegalArgumentException("atlas cannot be null.");
    this.atlas = atlas;
  }

  public RegionAttachment newRegionAttachment (Skin skin, String name, String path) {
    AtlasRegion region = atlas.findRegion(path);
    if (region == null)
      throw new RuntimeException("Region not found in atlas: " + path + " (region attachment: " + name + ")");
    RegionAttachment attachment = new RegionAttachment(name);
    attachment.setRegion(region);
    return attachment;
View Full Code Here

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

    attachment.setRegion(region);
    return attachment;
  }

  public MeshAttachment newMeshAttachment (Skin skin, String name, String path) {
    AtlasRegion region = atlas.findRegion(path);
    if (region == null) throw new RuntimeException("Region not found in atlas: " + path + " (mesh attachment: " + name + ")");
    MeshAttachment attachment = new MeshAttachment(name);
    attachment.setRegion(region);
    return attachment;
  }
View Full Code Here

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

    attachment.setRegion(region);
    return attachment;
  }

  public SkinnedMeshAttachment newSkinnedMeshAttachment (Skin skin, String name, String path) {
    AtlasRegion region = atlas.findRegion(path);
    if (region == null)
      throw new RuntimeException("Region not found in atlas: " + path + " (skinned mesh attachment: " + name + ")");
    SkinnedMeshAttachment attachment = new SkinnedMeshAttachment(name);
    attachment.setRegion(region);
    return attachment;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.