|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.tiled.TiledMap
public class TiledMap
This class is intended to parse TilED maps. TilED is a generic tool for tile map editing and can be found at: http://mapeditor.org/
Nested Class Summary | |
---|---|
protected class |
TiledMap.GroupObject
An object from a object-group on the map |
protected class |
TiledMap.ObjectGroup
A group of objects on the map (objects layer) |
Field Summary | |
---|---|
protected int |
height
The height of the map |
protected static int |
ISOMETRIC
Indicates an isometric map |
protected java.util.ArrayList |
layers
The list of layers defined in the map |
protected java.util.ArrayList |
objectGroups
The list of object-groups defined in the map |
protected int |
orientation
The orientation of this map |
protected static int |
ORTHOGONAL
Indicates a orthogonal map |
protected java.util.Properties |
props
the properties of the map |
protected int |
tileHeight
The height of the tiles used on the map |
protected java.util.ArrayList |
tileSets
The list of tilesets defined in the map |
protected java.lang.String |
tilesLocation
The location prefix where we can find tileset images |
protected int |
tileWidth
The width of the tiles used on the map |
protected int |
width
The width of the map |
Constructor Summary | |
---|---|
TiledMap(java.io.InputStream in)
Load a tile map from an arbitary input stream |
|
TiledMap(java.io.InputStream in,
java.lang.String tileSetsLocation)
Load a tile map from an arbitary input stream |
|
TiledMap(java.lang.String ref)
Create a new tile map based on a given TMX file |
|
TiledMap(java.lang.String ref,
boolean loadTileSets)
Create a new tile map based on a given TMX file |
|
TiledMap(java.lang.String ref,
java.lang.String tileSetsLocation)
Create a new tile map based on a given TMX file |
Method Summary | |
---|---|
TileSet |
findTileSet(int gid)
Find a tile for a given global tile id |
int |
getHeight()
Get the height of the map |
int |
getLayerCount()
Retrieve a count of the number of layers available |
int |
getLayerIndex(java.lang.String name)
Get the index of the layer with given name |
java.lang.String |
getLayerProperty(int layerIndex,
java.lang.String propertyName,
java.lang.String def)
Get a property given to a particular layer. |
java.lang.String |
getMapProperty(java.lang.String propertyName,
java.lang.String def)
Get a property given to the map. |
int |
getObjectCount(int groupID)
Returns the number of objects of a specific object-group. |
int |
getObjectGroupCount()
Returns the number of object-groups defined in the map. |
int |
getObjectHeight(int groupID,
int objectID)
Returns the height of a specific object from a specific group. |
java.lang.String |
getObjectImage(int groupID,
int objectID)
Retrieve the image source property for a given object |
java.lang.String |
getObjectName(int groupID,
int objectID)
Return the name of a specific object from a specific group. |
java.lang.String |
getObjectProperty(int groupID,
int objectID,
java.lang.String propertyName,
java.lang.String def)
Looks for a property with the given name and returns it's value. |
java.lang.String |
getObjectType(int groupID,
int objectID)
Return the type of an specific object from a specific group. |
int |
getObjectWidth(int groupID,
int objectID)
Returns the width of a specific object from a specific group. |
int |
getObjectX(int groupID,
int objectID)
Returns the x-coordinate of a specific object from a specific group. |
int |
getObjectY(int groupID,
int objectID)
Returns the y-coordinate of a specific object from a specific group. |
int |
getTileHeight()
Get the height of a single tile |
int |
getTileId(int x,
int y,
int layerIndex)
Get the global ID of a tile at specified location in the map |
Image |
getTileImage(int x,
int y,
int layerIndex)
Gets the Image used to draw the tile at the given x and y coordinates. |
java.lang.String |
getTileProperty(int tileID,
java.lang.String propertyName,
java.lang.String def)
Get a propety given to a particular tile. |
TileSet |
getTileSet(int index)
Get a tileset at a particular index in the list of sets for this map |
TileSet |
getTileSetByGID(int gid)
Get a tileset by a given global ID |
int |
getTileSetCount()
Retrieve the number of tilesets available in this map |
java.lang.String |
getTilesLocation()
Get the location of the tile images specified |
int |
getTileWidth()
Get the width of a single tile |
int |
getWidth()
Get the width of the map |
void |
render(int x,
int y)
Render the whole tile map at a given location |
void |
render(int x,
int y,
int layer)
Render a single layer from the map |
void |
render(int x,
int y,
int sx,
int sy,
int width,
int height)
Render a section of the tile map |
void |
render(int x,
int y,
int sx,
int sy,
int width,
int height,
boolean lineByLine)
Render a section of the tile map |
void |
render(int x,
int y,
int sx,
int sy,
int width,
int height,
int l,
boolean lineByLine)
Render a section of the tile map |
protected void |
renderedLine(int visualY,
int mapY,
int layer)
Overrideable to allow other sprites to be rendered between lines of the map |
protected void |
renderIsometricMap(int x,
int y,
int sx,
int sy,
int width,
int height,
Layer layer,
boolean lineByLine)
Render of isometric map renders. |
void |
setTileId(int x,
int y,
int layerIndex,
int tileid)
Set the global ID of a tile at specified location in the map |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int width
protected int height
protected int tileWidth
protected int tileHeight
protected java.lang.String tilesLocation
protected java.util.Properties props
protected java.util.ArrayList tileSets
protected java.util.ArrayList layers
protected java.util.ArrayList objectGroups
protected static final int ORTHOGONAL
protected static final int ISOMETRIC
protected int orientation
Constructor Detail |
---|
public TiledMap(java.lang.String ref) throws SlickException
ref
- The location of the tile map to load
SlickException
- Indicates a failure to load the tilemappublic TiledMap(java.lang.String ref, boolean loadTileSets) throws SlickException
ref
- The location of the tile map to loadloadTileSets
- True if we want to load tilesets - including their image data
SlickException
- Indicates a failure to load the tilemappublic TiledMap(java.lang.String ref, java.lang.String tileSetsLocation) throws SlickException
ref
- The location of the tile map to loadtileSetsLocation
- The location where we can find the tileset images and other
resources
SlickException
- Indicates a failure to load the tilemappublic TiledMap(java.io.InputStream in) throws SlickException
in
- The input stream to load from
SlickException
- Indicates a failure to load the tilemappublic TiledMap(java.io.InputStream in, java.lang.String tileSetsLocation) throws SlickException
in
- The input stream to load fromtileSetsLocation
- The location at which we can find tileset images
SlickException
- Indicates a failure to load the tilemapMethod Detail |
---|
public java.lang.String getTilesLocation()
public int getLayerIndex(java.lang.String name)
name
- The name of the tile to search for
public Image getTileImage(int x, int y, int layerIndex)
x
- The x coordinate of the tile whose image should be retrievedy
- The y coordinate of the tile whose image should be retrievedlayerIndex
- The index of the layer on which the tile whose image should be
retrieve exists
public int getWidth()
public int getHeight()
public int getTileHeight()
public int getTileWidth()
public int getTileId(int x, int y, int layerIndex)
x
- The x location of the tiley
- The y location of the tilelayerIndex
- The index of the layer to retireve the tile from
public void setTileId(int x, int y, int layerIndex, int tileid)
x
- The x location of the tiley
- The y location of the tilelayerIndex
- The index of the layer to set the new tileidtileid
- The tileid to be setpublic java.lang.String getMapProperty(java.lang.String propertyName, java.lang.String def)
propertyName
- The name of the property of the map to retrievedef
- The default value to return
public java.lang.String getLayerProperty(int layerIndex, java.lang.String propertyName, java.lang.String def)
layerIndex
- The index of the layer to retrievepropertyName
- The name of the property of this layer to retrievedef
- The default value to return
public java.lang.String getTileProperty(int tileID, java.lang.String propertyName, java.lang.String def)
tileID
- The global ID of the tile to retrievepropertyName
- The name of the property to retirevedef
- The default value to return
public void render(int x, int y)
x
- The x location to render aty
- The y location to render atpublic void render(int x, int y, int layer)
x
- The x location to render aty
- The y location to render atlayer
- The layer to renderpublic void render(int x, int y, int sx, int sy, int width, int height)
x
- The x location to render aty
- The y location to render atsx
- The x tile location to start renderingsy
- The y tile location to start renderingwidth
- The width of the section to render (in tiles)height
- The height of the secton to render (in tiles)public void render(int x, int y, int sx, int sy, int width, int height, int l, boolean lineByLine)
x
- The x location to render aty
- The y location to render atsx
- The x tile location to start renderingsy
- The y tile location to start renderingwidth
- The width of the section to render (in tiles)height
- The height of the secton to render (in tiles)l
- The index of the layer to renderlineByLine
- True if we should render line by line, i.e. giving us a chance
to render something else between lines (@see
renderedLine(int, int, int)
public void render(int x, int y, int sx, int sy, int width, int height, boolean lineByLine)
x
- The x location to render aty
- The y location to render atsx
- The x tile location to start renderingsy
- The y tile location to start renderingwidth
- The width of the section to render (in tiles)height
- The height of the secton to render (in tiles)lineByLine
- True if we should render line by line, i.e. giving us a chance
to render something else between lines (@see
renderedLine(int, int, int)
protected void renderIsometricMap(int x, int y, int sx, int sy, int width, int height, Layer layer, boolean lineByLine)
x
- The x location to render aty
- The y location to render atsx
- The x tile location to start renderingsy
- The y tile location to start renderingwidth
- The width of the section to render (in tiles)height
- The height of the section to render (in tiles)layer
- if this is null all layers are rendered, if not only the
selected layer is rendereredlineByLine
- True if we should render line by line, i.e. giving us a chance
to render something else between lines (@see
renderedLine(int, int, int)
TODO: [Isometric map] Render stuff between lines, concept of
line differs from ortho mapspublic int getLayerCount()
public int getTileSetCount()
public TileSet getTileSet(int index)
index
- The index of the tileset.
public TileSet getTileSetByGID(int gid)
gid
- The global ID of the tileset to retrieve
public TileSet findTileSet(int gid)
gid
- The global tile id we're looking for
protected void renderedLine(int visualY, int mapY, int layer)
visualY
- The visual Y coordinate, i.e. 0->heightmapY
- The map Y coordinate, i.e. y->y+heightlayer
- The layer being renderedpublic int getObjectGroupCount()
public int getObjectCount(int groupID)
groupID
- The index of this object-group
public java.lang.String getObjectName(int groupID, int objectID)
groupID
- Index of a groupobjectID
- Index of an object
public java.lang.String getObjectType(int groupID, int objectID)
groupID
- Index of a groupobjectID
- Index of an object
public int getObjectX(int groupID, int objectID)
groupID
- Index of a groupobjectID
- Index of an object
public int getObjectY(int groupID, int objectID)
groupID
- Index of a groupobjectID
- Index of an object
public int getObjectWidth(int groupID, int objectID)
groupID
- Index of a groupobjectID
- Index of an object
public int getObjectHeight(int groupID, int objectID)
groupID
- Index of a groupobjectID
- Index of an object
public java.lang.String getObjectImage(int groupID, int objectID)
groupID
- Index of a groupobjectID
- Index of an object
public java.lang.String getObjectProperty(int groupID, int objectID, java.lang.String propertyName, java.lang.String def)
groupID
- Index of a groupobjectID
- Index of an objectpropertyName
- Name of a propertydef
- default value to return, if no property is found
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |