|
BenQ Mobile |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.microedition.lcdui.game.Layer
javax.microedition.lcdui.game.TiledLayer
Description:
Tiles:
Constructor Summary | |
TiledLayer(int columns,
int rows,
Image image,
int tileWidth,
int tileHeight)
Creates a new TiledLayer. |
Method Summary | |
int |
createAnimatedTile(int staticTileIndex)
Creates a new animated tile and returns the index that refers to the new animated tile. |
void |
fillCells(int col,
int row,
int width,
int height,
int tileIndex)
Fills an area of cells. |
int |
getAnimatedTile(int animatedTileIndex)
Gets the tile referenced by an animated tile. |
int |
getCell(int col,
int row)
Gets the contents of a cell. |
int |
getCellHeight()
Gets the height of a single cell, in pixels. |
int |
getCellWidth()
Gets the width of a single cell, in pixels. |
int |
getColumns()
Gets the width of the TiledLayer grid. |
int |
getRows()
Gets the height of the TiledLayer grid. |
void |
paint(Graphics g)
Draws the TiledLayer. |
void |
setAnimatedTile(int animatedTileIndex,
int staticTileIndex)
Associates an animated tile with the specified static tile. |
void |
setCell(int col,
int row,
int tileIndex)
Sets the contents of a cell. |
void |
setStaticTileSet(Image image,
int tileWidth,
int tileHeight)
Change the static tile set. |
Methods inherited from class javax.microedition.lcdui.game.Layer |
getHeight, getWidth, getX, getY, isVisible, move, setPosition, setVisible |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TiledLayer(int columns, int rows, Image image, int tileWidth, int tileHeight)
The static tile set for the TiledLayer is created from the specified Image with each tile having the dimensions of tileWidth x tileHeight. The width of the source image must be an integer multiple of the tile width, and the height of the source image must be an integer multiple of the tile height; otherwise, an Illegal- ArgumentException is thrown;
The entire static tile set can be changed using setStaticTileSet(Image, int, int). These methods should be used sparingly since they are both memory and time consuming. Where possible, animated tiles should be used instead to animate tile appearance.
columns
- Width of the TiledLayer, expressed as a number of cellsrows
- Height of the TiledLayer, expressed as a number of cellsimage
- Image to use for creating the static tile settileWidth
- The width, in pixels, of a single tiletileHeight
- The height, in pixels, of a single tile
java.lang.NullPointerException
- if image is null
java.lang.IllegalArgumentException
- if the number of rows or columns is less than 1
java.lang.IllegalArgumentException
- if tileHeight or tileWidth is less than 1
java.lang.IllegalArgumentException
- if the image width is not an integer multiple of the tileWidth
java.lang.IllegalArgumentException
- if the image height is not an integer multiple of the tileHeight
java.lang.IllegalArgumentException
- if the resulting number if tiles exceeds 32,767
java.lang.OutOfMemoryError
- if the request exceeds the resource availability of the deviceMethod Detail |
public int createAnimatedTile(int staticTileIndex)
staticTileIndex
- Index of the associated tile (must be 0 or a valid static tile index)
java.lang.IndexOutOfBoundsException
- If the staticTileIndex is invalid
java.lang.IllegalArgumentException
- if the request will result in more than 32,767 animated tiles.public void fillCells(int col, int row, int width, int height, int tileIndex)
col
- Column of top-left cell in the arearow
- Row of top-left cell in the areawidth
- The width of the area, expressed as a number of cellsheight
- The height of the area, expressed as a number of cellstileIndex
- The Index of the tile to place in all cells in the specified area
java.lang.IndexOutOfBoundsException
- if the rectangular region defined by the parameters extends
beyond the bounds of the TiledLayer grid
java.lang.IndexOutOfBoundsException
- if there is no tile with index tileIndexpublic int getAnimatedTile(int animatedTileIndex)
animatedTileIndex
- Index of the animated tile
java.lang.IndexOutOfBoundsException
- If the animated tile index is invalidpublic int getCell(int col, int row)
col
- Column of cell to checkrow
- Row of cell to check
java.lang.IndexOutOfBoundsException
- if row or col is outside the bounds of the TiledLayer gridpublic final int getCellHeight()
public final int getCellWidth()
public final int getColumns()
public final int getRows()
public final void paint(Graphics g)
paint
in class Layer
g
- Graphics object to draw the TiledLayer
java.lang.NullPointerException
- if g is nullpublic void setAnimatedTile(int animatedTileIndex, int staticTileIndex)
animatedTileIndex
- Index of the animated tilestaticTileIndex
- Index of the associated tile (must be 0 or a valid static tile index)
java.lang.IndexOutOfBoundsException
- If the staticTileIndex is invalid
java.lang.IndexOutOfBoundsException If the animated tile index is invalidpublic void setCell(int col, int row, int tileIndex)
col
- Column of cell to setrow
- Row of cell to settileIndex
- Index of tile to place in cell
java.lang.IndexOutOfBoundsException
- if there is no tile with index tileIndex
java.lang.IndexOutOfBoundsException
- if row or col is outside the bounds of the TiledLayer gridpublic void setStaticTileSet(Image image, int tileWidth, int tileHeight)
If the new static tile set has as many or more tiles than the previous static tile set, the animated tiles and cell contents will be preserve. If not, the contents of the grid will be cleared (all cells will contain index 0) and all animated tiles will be deleted.
image
- Image to use for creating the static tile settileWidth
- The width, in pixels, of a single tiletileHeight
- The height, in pixels, of a single tile
java.lang.NullPointerException
- if image is null
java.lang.IllegalArgumentException
- if tileHeight or tileWidth is less than 1
java.lang.IllegalArgumentException
- if the image width is not an integer multiple of the tileWidth
java.lang.IllegalArgumentException
- if the image height is not an integer multiple of the tileHeight
java.lang.IllegalArgumentException
- if the resulting number if tiles exceeds 32,767
|
BenQ Mobile |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2006 BenQ Mobile GmbH & Co. OHG or respective copyright owner. All Rights Reserved. BenQ Corp. is a trademark licensee of Siemens AG. |
For further information about Mobility Toolkit (MTK) visit our Developer Portal. |