Back to project page game-api-android.
The source code is released under:
MIT License
If you think the Android project game-api-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package android.gameengine.icadroids.tiles; //from www .ja v a 2 s.com /** * Every tile in a tilemap is a tile object. You can manipulate the tile by * using its methods. * * Note: tile objects will be automatically generated by GameTiles * * @author Bas van der Zandt * */ public class Tile { private int tileType; /** * The position of the tiles in the tilemap. This is NOT the x and y * position in the game world! */ private int tileNumberX, tileNumberY; /** * This tile object is instance of this gameTiles object */ private GameTiles gameTiles; /** * Every tile has a tiletype and is a instance of an gameTiles object. * Tiletype lower than 0 means invisible. * * @param tileType * @param gameTiles */ public Tile(int tileType, GameTiles gameTiles) { super(); this.tileType = tileType; this.gameTiles = gameTiles; } /** * Change the tile type<br /> * <em>Important!</em> Use this method only when you want to change a tile * into another tile. If you want to remove tiles or add tiles at certain positions, * use the GameTiles.changeTile method. * * @param tileType * the new tiletype * @see android.gameengine.icadroids.tiles.GameTiles#changeTile(int, int, int) */ public void setTileType(int tileType) { this.tileType = tileType; } /** * Get the tile tiletype * * @return the tiletype */ public int getTileType() { return tileType; } /** * Get the x tile number <b> in the tile map </b> * * @return The x tile number */ public int getTileNumberX() { return tileNumberX; } /** * Get the y tile number <b> in the tile map </b> * * @return The y tile number */ public int getTileNumberY() { return tileNumberY; } /** * Set the position of the tile in the tilemap, as index, not real world coordinates * * @param i the first index in the double array of the tilemap, that is Y-index * @param j the second index in the double array of the tilemap, that is X-index */ void setTileIndex(int i, int j) { tileNumberX = j; tileNumberY = i; } /** * Get the instance of gameTiles where this Tile is a instance from * * @return gameTile object */ public GameTiles getGameTiles() { return gameTiles; } /** * Get the x position of the tile Note: x and y values are at the top left * corner of the tile * * @return the x position in the game world */ public int getTileX() { return tileNumberX * gameTiles.tileSize; } /** * get the y position of the tile Note: x and y values are at the top left * corner of the tile * * @return the y position in the game world */ public int getTileY() { return tileNumberY * gameTiles.tileSize; } }