|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.gameengine.icadroids.tiles.GameTiles
public class GameTiles
Gametiles are especially useful if you want to quickly build a level/map (walls, floor, etc) for a platform- or boardgame. This class makes for every tile a seperated object and place it on the right position. The tile objects can be manipulated separately.
Field Summary | |
---|---|
int |
tileSize
The width and height of every tile. |
java.util.Vector<Sprite> |
tileTypes
Array that holds different TileTypes with each it's own sprites and behavior. |
Constructor Summary | |
---|---|
GameTiles(int tileSize)
This overloaded constructor will make an GameTile object with an empty tilemap. |
|
GameTiles(java.lang.String[] tileResources,
int[][] map,
int tileSize)
Make a new tilemap object with the given tile resources, the tilemap and the tile size |
Method Summary | |
---|---|
void |
addTileMap(int[][] map,
int tileSize)
Add / replace the current tile map. |
void |
addTileResources(java.lang.String[] resourceNames)
Add resources to the list |
void |
changeTile(int xTile,
int yTile,
int tileType)
Change a tile in the game world, add or remove a tile. |
void |
drawTiles(Canvas c)
Loop through the TileArray to draw the Tiles. |
int |
getMapHeigth()
Get the height of the map |
int |
getMapWidth()
Get the width of the map |
Tile[][] |
getTileArray()
Get the list with all the Tile objects in it. |
Tile |
getTileOnIndex(int xIndex,
int yIndex)
get a Tile on a specified index number of the tile list |
Tile |
getTileOnPosition(int xPosition,
int yPosition)
Get a tile on a specific x and y position in the game world |
java.util.Vector<Sprite> |
getTileTypes()
|
void |
setTileTypes(java.util.Vector<Sprite> tileTypes)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.util.Vector<Sprite> tileTypes
public int tileSize
Constructor Detail |
---|
public GameTiles(java.lang.String[] tileResources, int[][] map, int tileSize)
tileResources
- a list of string with the names of the images you want to use
in the tilemap. This images have only the name of the images
without the extension! For example: new String[] = {"tile1",
"tile2", "tile3"};map
- An 2d Array of the overlay map. The numbers are the position
of the tileResources, starting at 0. -1 means invisible Tile.
Example: new Int[][] = {{0,-1,2,2,-1},{1,1,-1,2,-1}}tileSize
- The size of a tile. This size is the width and height of a
tile.public GameTiles(int tileSize)
tileSize
- Method Detail |
---|
public void addTileMap(int[][] map, int tileSize)
map
- An 2d Array of the overlay map. The numbers are the position
of the tileResources, starting at 0. -1 means invisible Tile.
Example: new Int[][] = {{0,-1,2,2,-1},{1,1,-1,2,-1}}tileSize
- The size of a tile. This size is the width and height of a
tile.public void drawTiles(Canvas c)
public void changeTile(int xTile, int yTile, int tileType)
yTile
- the y-pos of the tile in the tile arrayxTile
- the y-pos of the tile in the tile arraytileType
- the new sprite type that should replace this tilepublic java.util.Vector<Sprite> getTileTypes()
public void setTileTypes(java.util.Vector<Sprite> tileTypes)
tileTypes
- the tileTypes to setpublic Tile[][] getTileArray()
public void addTileResources(java.lang.String[] resourceNames)
resourceNames
- all resources you want to add to the listpublic int getMapHeigth()
public int getMapWidth()
public Tile getTileOnPosition(int xPosition, int yPosition)
xPosition
- x position of the tileyPosition
- y position of the tile
public Tile getTileOnIndex(int xIndex, int yIndex)
xIndex
- The x index of the listyIndex
- The y index of the List
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |