public class TextureAtlas extends java.lang.Object implements Disposable
Modifier and Type | Class and Description |
---|---|
static class |
TextureAtlas.AtlasRegion
Describes the region of a packed image and provides information about the original image before it was packed.
|
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.
|
static class |
TextureAtlas.TextureAtlasData |
Constructor and Description |
---|
TextureAtlas()
Creates an empty atlas to which regions can be added.
|
TextureAtlas(FileHandle packFile)
Loads the specified pack file, using the parent directory of the pack file to find the page images.
|
TextureAtlas(FileHandle packFile,
boolean flip) |
TextureAtlas(FileHandle packFile,
FileHandle imagesDir) |
TextureAtlas(FileHandle packFile,
FileHandle imagesDir,
boolean flip) |
TextureAtlas(java.lang.String internalPackFile)
Loads the specified pack file using
Files.FileType.Internal , using the parent directory of the pack file to find the page
images. |
TextureAtlas(TextureAtlas.TextureAtlasData data) |
Modifier and Type | Method and Description |
---|---|
TextureAtlas.AtlasRegion |
addRegion(java.lang.String name,
Texture texture,
int x,
int y,
int width,
int height)
Adds a region to the atlas.
|
TextureAtlas.AtlasRegion |
addRegion(java.lang.String name,
TextureRegion textureRegion)
Adds a region to the atlas.
|
NinePatch |
createPatch(java.lang.String name)
Returns the first region found with the specified name as a
NinePatch . |
Sprite |
createSprite(java.lang.String name)
Returns the first region found with the specified name as a sprite.
|
Sprite |
createSprite(java.lang.String name,
int index)
Returns the first region found with the specified name and index as a sprite.
|
Array<Sprite> |
createSprites()
Returns all regions in the atlas as sprites.
|
Array<Sprite> |
createSprites(java.lang.String name)
Returns all regions with the specified name as sprites, ordered by smallest to largest
index . |
void |
dispose()
Releases all resources associated with this TextureAtlas instance.
|
TextureAtlas.AtlasRegion |
findRegion(java.lang.String name)
Returns the first region found with the specified name.
|
TextureAtlas.AtlasRegion |
findRegion(java.lang.String name,
int index)
Returns the first region found with the specified name and index.
|
Array<TextureAtlas.AtlasRegion> |
findRegions(java.lang.String name)
Returns all regions with the specified name, ordered by smallest to largest
index . |
Array<TextureAtlas.AtlasRegion> |
getRegions()
Returns all regions in the atlas.
|
ObjectSet<Texture> |
getTextures() |
void |
load(TextureAtlas.TextureAtlasData data)
Adds the textures and regions from the specified texture atlas data.
|
public TextureAtlas()
public TextureAtlas(java.lang.String internalPackFile)
Files.FileType.Internal
, using the parent directory of the pack file to find the page
images.public TextureAtlas(FileHandle packFile)
public TextureAtlas(FileHandle packFile, boolean flip)
flip
- If true, all regions loaded will be flipped for use with a perspective where 0,0 is the upper left corner.TextureAtlas(FileHandle)
public TextureAtlas(FileHandle packFile, FileHandle imagesDir)
public TextureAtlas(FileHandle packFile, FileHandle imagesDir, boolean flip)
flip
- If true, all regions loaded will be flipped for use with a perspective where 0,0 is the upper left corner.public TextureAtlas(TextureAtlas.TextureAtlasData data)
public void load(TextureAtlas.TextureAtlasData data)
public TextureAtlas.AtlasRegion addRegion(java.lang.String name, Texture texture, int x, int y, int width, int height)
public TextureAtlas.AtlasRegion addRegion(java.lang.String name, TextureRegion textureRegion)
public Array<TextureAtlas.AtlasRegion> getRegions()
@Null public TextureAtlas.AtlasRegion findRegion(java.lang.String name)
@Null public TextureAtlas.AtlasRegion findRegion(java.lang.String name, int index)
public Array<TextureAtlas.AtlasRegion> findRegions(java.lang.String name)
index
. This method
uses string comparison to find the regions, so the result should be cached rather than calling this method multiple
times.public Array<Sprite> createSprites()
createSprite(String)
@Null public Sprite createSprite(java.lang.String name)
@Null public Sprite createSprite(java.lang.String name, int index)
createSprite(String)
public Array<Sprite> createSprites(java.lang.String name)
index
.
This method uses string comparison to find the regions and constructs new sprites, so the result should be cached rather
than calling this method multiple times.createSprite(String)
@Null public NinePatch createPatch(java.lang.String name)
NinePatch
. The region must have been packed with
ninepatch splits. This method uses string comparison to find the region and constructs a new ninepatch, so the result should
be cached rather than calling this method multiple times.public void dispose()
dispose
in interface Disposable