public class TileManager extends Object
Loading tilesets by hand is intended for things like toolbar icons or games with a single set of tiles (think Stratego, for example). Loading tilesets from a repository supports games with vast numbers of tiles to which more tiles may be added on the fly (think the tiles for an isometric-display graphical MUD).
| Constructor and Description |
|---|
TileManager(ImageManager imgr)
Creates a tile manager and provides it with a reference to the image manager from which it
will load tileset images.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearCache()
Clears any cached tilesets.
|
ImageProvider |
getImageProvider(String rset)
Returns an image provider that will load images from the specified resource set.
|
Tile |
getTile(int fqTileId)
Returns the
Tile object with the specified fully qualified tile id. |
Tile |
getTile(int tileSetId,
int tileIndex,
TileSet.Colorizer rizer)
Returns the
Tile object from the specified tileset at the specified index. |
Tile |
getTile(int fqTileId,
TileSet.Colorizer rizer)
Returns the
Tile object with the specified fully qualified tile id. |
TileSet |
getTileSet(int tileSetId)
Returns the tileset with the specified id.
|
TileSet |
getTileSet(String name)
Returns the tileset with the specified name.
|
TileSetRepository |
getTileSetRepository()
Returns the tileset repository currently in use.
|
UniformTileSet |
loadTileSet(ImageProvider improv,
String improvKey,
String imgPath,
int width,
int height) |
UniformTileSet |
loadTileSet(String imgPath,
int width,
int height)
Loads up a tileset from the specified image with the specified metadata parameters.
|
UniformTileSet |
loadTileSet(String rset,
String imgPath,
int width,
int height)
Loads up a tileset from the specified image (located in the specified resource set) with
the specified metadata parameters.
|
void |
setTileSetRepository(TileSetRepository setrep)
Sets the tileset repository that will be used by the tile manager when tiles are requested
by tileset id.
|
public TileManager(ImageManager imgr)
imgr - the image manager via which the tile manager will decode and cache images.public UniformTileSet loadTileSet(String imgPath, int width, int height)
public UniformTileSet loadTileSet(String rset, String imgPath, int width, int height)
public UniformTileSet loadTileSet(ImageProvider improv, String improvKey, String imgPath, int width, int height)
public ImageProvider getImageProvider(String rset)
public void clearCache()
public void setTileSetRepository(TileSetRepository setrep)
public TileSetRepository getTileSetRepository()
public TileSet getTileSet(int tileSetId) throws NoSuchTileSetException
setTileSetRepository(com.threerings.media.tile.TileSetRepository), and are subsequently cached.tileSetId - the unique identifier for the desired tileset.NoSuchTileSetException - thrown if no tileset exists with the specified id or if
an underlying error occurs with the tileset repository's persistence mechanism.public TileSet getTileSet(String name) throws NoSuchTileSetException
NoSuchTileSetException - if no tileset with the specified name is available via our
configured tile set repository.public Tile getTile(int fqTileId) throws NoSuchTileSetException
Tile object with the specified fully qualified tile id.NoSuchTileSetExceptionTileUtil.getFQTileId(int, int)public Tile getTile(int fqTileId, TileSet.Colorizer rizer) throws NoSuchTileSetException
Tile object with the specified fully qualified tile id. The supplied
colorizer will be used to recolor the tile.NoSuchTileSetExceptionTileUtil.getFQTileId(int, int)public Tile getTile(int tileSetId, int tileIndex, TileSet.Colorizer rizer) throws NoSuchTileSetException
Tile object from the specified tileset at the specified index.tileSetId - the tileset id.tileIndex - the index of the tile to be retrieved.NoSuchTileSetExceptionCopyright © 2015. All rights reserved.