public class Skin extends Object implements Disposable
See the documentation for more.
Modifier and Type | Class and Description |
---|---|
static class |
Skin.TintedDrawable |
Constructor and Description |
---|
Skin()
Creates an empty skin.
|
Skin(FileHandle skinFile)
Creates a skin containing the resources in the specified skin JSON file.
|
Skin(FileHandle skinFile,
TextureAtlas atlas)
Creates a skin containing the resources in the specified skin JSON file and the texture regions from the specified atlas.
|
Skin(TextureAtlas atlas)
Creates a skin containing the texture regions from the specified atlas.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String name,
Object resource) |
void |
add(String name,
Object resource,
Class type) |
void |
addRegions(TextureAtlas atlas)
Adds all named texture regions from the atlas.
|
void |
dispose()
Disposes the
TextureAtlas and all Disposable resources in the skin. |
String |
find(Object resource)
Returns the name of the specified style object, or null if it is not in the skin.
|
<T> T |
get(Class<T> type)
Returns a resource named "default" for the specified type.
|
<T> T |
get(String name,
Class<T> type)
Returns a named resource of the specified type.
|
<T> ObjectMap<String,T> |
getAll(Class<T> type)
Returns the name to resource mapping for the specified type, or null if no resources of that type exist.
|
TextureAtlas |
getAtlas()
Returns the
TextureAtlas passed to this skin constructor, or null. |
Color |
getColor(String name) |
Drawable |
getDrawable(String name)
Returns a registered drawable.
|
BitmapFont |
getFont(String name) |
NinePatch |
getPatch(String name)
Returns a registered ninepatch.
|
TextureRegion |
getRegion(String name)
Returns a registered texture region.
|
Array<TextureRegion> |
getRegions(String regionName) |
Sprite |
getSprite(String name)
Returns a registered sprite.
|
TiledDrawable |
getTiledDrawable(String name)
Returns a registered tiled drawable.
|
boolean |
has(String name,
Class type) |
void |
load(FileHandle skinFile)
Adds all resources in the specified skin JSON file.
|
Drawable |
newDrawable(Drawable drawable)
Returns a copy of the specified drawable.
|
Drawable |
newDrawable(Drawable drawable,
Color tint)
Returns a tinted copy of a drawable found in the skin via
getDrawable(String) . |
Drawable |
newDrawable(Drawable drawable,
float r,
float g,
float b,
float a)
Returns a tinted copy of a drawable found in the skin via
getDrawable(String) . |
Drawable |
newDrawable(String name)
Returns a copy of a drawable found in the skin via
getDrawable(String) . |
Drawable |
newDrawable(String name,
Color tint)
Returns a tinted copy of a drawable found in the skin via
getDrawable(String) . |
Drawable |
newDrawable(String name,
float r,
float g,
float b,
float a)
Returns a tinted copy of a drawable found in the skin via
getDrawable(String) . |
<T> T |
optional(String name,
Class<T> type)
Returns a named resource of the specified type.
|
void |
remove(String name,
Class type) |
void |
setEnabled(Actor actor,
boolean enabled)
Sets the style on the actor to disabled or enabled.
|
public Skin()
public Skin(FileHandle skinFile)
TextureAtlas
and the texture regions added to the skin. The atlas is
automatically disposed when the skin is disposed.public Skin(FileHandle skinFile, TextureAtlas atlas)
public Skin(TextureAtlas atlas)
public void load(FileHandle skinFile)
public void addRegions(TextureAtlas atlas)
public <T> T get(Class<T> type)
GdxRuntimeException
- if the resource was not found.public <T> T get(String name, Class<T> type)
GdxRuntimeException
- if the resource was not found.public <T> T optional(String name, Class<T> type)
public <T> ObjectMap<String,T> getAll(Class<T> type)
public BitmapFont getFont(String name)
public TextureRegion getRegion(String name)
public Array<TextureRegion> getRegions(String regionName)
TextureRegion
that have an index != -1, or null if none are found.public TiledDrawable getTiledDrawable(String name)
public NinePatch getPatch(String name)
TextureAtlas.AtlasRegion
then the TextureAtlas.AtlasRegion.splits
are used,
otherwise the ninepatch will have the region as the center patch.public Sprite getSprite(String name)
TextureAtlas.AtlasRegion
then an TextureAtlas.AtlasSprite
is used if the region has been
whitespace stripped or packed rotated 90 degrees.public Drawable getDrawable(String name)
public String find(Object resource)
public Drawable newDrawable(String name)
getDrawable(String)
.public Drawable newDrawable(String name, float r, float g, float b, float a)
getDrawable(String)
.public Drawable newDrawable(String name, Color tint)
getDrawable(String)
.public Drawable newDrawable(Drawable drawable)
public Drawable newDrawable(Drawable drawable, float r, float g, float b, float a)
getDrawable(String)
.public Drawable newDrawable(Drawable drawable, Color tint)
getDrawable(String)
.public void setEnabled(Actor actor, boolean enabled)
public TextureAtlas getAtlas()
TextureAtlas
passed to this skin constructor, or null.public void dispose()
TextureAtlas
and all Disposable
resources in the skin.dispose
in interface Disposable
Copyright © 2016. All rights reserved.