APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.graphics.g2d

public Class TextureAtlas

extends Object
implements Disposable
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.utils.Disposable
Imports
java.io.BufferedReader, java.util.Comparator, com.badlogic.gdx.Files.FileType, .Gdx, com.badlogic.gdx.files.FileHandle, com.badlogic.gdx.graphics.Pixmap.Format, .Texture, .Texture.TextureFilter, .Texture.TextureWrap, com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Page, .TextureAtlas.TextureAtlasData.Region, com.badlogic.gdx.utils.Array, .Disposable, .GdxRuntimeException, .Null, .ObjectMap, .ObjectSet, .StreamUtils

Loads images from texture atlases created by TexturePacker.

A TextureAtlas must be disposed to free up the resources consumed by the backing textures.
Author
Nathan Sweet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
TextureAtlas.AtlasRegion

Describes the region of a packed image and provides information about the original image before it was packed.

public static class
TextureAtlas.AtlasSprite

A sprite that, if whitespace was stripped from the region when it was packed, is automatically positioned as if whitespace had not been stripped.

public static class

Field Summary

Modifier and TypeField and Description
private final Array<TextureAtlas.AtlasRegion>
private final ObjectSet<Texture>

Constructor Summary

AccessConstructor and Description
public
TextureAtlas()

Creates an empty atlas to which regions can be added.

public
TextureAtlas(String internalPackFile)

Loads the specified pack file using FileType#Internal, using the parent directory of the pack file to find the page images.

public
TextureAtlas(FileHandle packFile)

Loads the specified pack file, using the parent directory of the pack file to find the page images.

public
TextureAtlas(FileHandle packFile, boolean
If true, all regions loaded will be flipped for use with a perspective where 0,0 is the upper left corner.
flip
)

public
TextureAtlas(FileHandle packFile, FileHandle imagesDir)

public
TextureAtlas(FileHandle packFile, FileHandle imagesDir, boolean
If true, all regions loaded will be flipped for use with a perspective where 0,0 is the upper left corner.
flip
)

public

Method Summary

Modifier and TypeMethod and Description
public TextureAtlas.AtlasRegion
addRegion(String name, Texture texture, int x, int y, int width, int height)

Adds a region to the atlas.

public TextureAtlas.AtlasRegion
addRegion(String name, TextureRegion textureRegion)

Adds a region to the atlas.

public NinePatch
createPatch(String name)

Returns the first region found with the specified name as a NinePatch.

public Sprite
createSprite(String name)

Returns the first region found with the specified name as a sprite.

public Sprite
createSprite(String name, int index)

Returns the first region found with the specified name and index as a sprite.

public Array<Sprite>
createSprites()

Returns all regions in the atlas as sprites.

public Array<Sprite>
createSprites(String name)

Returns all regions with the specified name as sprites, ordered by smallest to largest index.

public void
dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Releases all resources associated with this TextureAtlas instance.

public TextureAtlas.AtlasRegion
findRegion(String name)

Returns the first region found with the specified name.

public TextureAtlas.AtlasRegion
findRegion(String name, int index)

Returns the first region found with the specified name and index.

public Array<TextureAtlas.AtlasRegion>
findRegions(String name)

Returns all regions with the specified name, ordered by smallest to largest index.

public Array<TextureAtlas.AtlasRegion>
getRegions()

Returns all regions in the atlas.

public ObjectSet<Texture>
getTextures()

Returns: the textures of the pages, unordered

public void
load(TextureAtlas.TextureAtlasData data)

Adds the textures and regions from the specified texture atlas data.

private Sprite
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait