|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.lcdui.game.Layer | +--javax.microedition.lcdui.game.TiledLayer | +--mgdk.MMap
Extends TiledLayer. Adds ability to load a map from a RecordSet or a resource file and to save it to a RecordSet.
TiledLayer
Field Summary | |
int |
clearColor
Color used to clear the buffer. |
Constructor Summary | |
MMap(int width,
int height,
java.lang.String imgName,
int cellWidth,
int cellHeight)
Creates an empty map and loads the specified image. |
Method Summary | |
protected static MMap |
create(byte[] data,
java.lang.String imgName,
int blockW,
int blockH)
Used internally to create a map from the supplied data. |
javax.microedition.lcdui.Image |
getBuffer()
Returns the maps buffer image, which you for example can use to look up pixels. |
int |
getCell(int number)
Get the tilenumber for the specified cell. |
int |
getCellNumber(int cellX,
int cellY)
Get cellnumber for cell at [cellX, cellY]. |
int |
getCellNumberAtPixel(int screenX,
int screenY)
Get the cellnumber for the cell found at the specified screen coordinates (in pixels). |
int |
getPixelX(int number)
Get the coordinate of the leftmost pixel in the cell with the specified number. |
int |
getPixelY(int number)
Get the coordinate of the topmost pixel in the cell with the specified number. |
static MMap |
loadFromFile(java.lang.String filename,
java.lang.String imgName,
int cellWidth,
int cellHeight)
Loads a map from a file located in /res. |
static MMap |
loadFromRS(java.lang.String recName,
java.lang.String imgName,
int cellWidth,
int cellHeight)
Have to return a new MMap since you can not resize am existing one... ? |
void |
modifyCellValue(int number,
int change)
Change the value of the specified cell. |
void |
paint(javax.microedition.lcdui.Graphics g,
int x,
int y)
Paint the map to the specified graphics object. |
void |
saveToRS(java.lang.String recName)
Save this map in a RecordStore (permanent storage). |
void |
setCell(int number,
int value)
Sets the tilenumber of the specified cell. |
void |
updateBuffer(boolean clear)
Updates the buffer image to show the maps current state. |
Methods inherited from class javax.microedition.lcdui.game.TiledLayer |
createAnimatedTile, fillCells, getAnimatedTile, getCell, getCellHeight, getCellWidth, getColumns, getRows, paint, setAnimatedTile, setCell, setStaticTileSet |
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 |
Field Detail |
public int clearColor
Constructor Detail |
public MMap(int width, int height, java.lang.String imgName, int cellWidth, int cellHeight)
width
- Map width in cells (number of columns)height
- Map height in cells (number of rows)imgName
- Filename of image used for cell tiles (pictures in the cells)cellWidth
- The width in pixels of each cellcellHeight
- The height in pixels of each cellMethod Detail |
public void saveToRS(java.lang.String recName)
recName
- Name of the RecordStore used to save the mapprotected static MMap create(byte[] data, java.lang.String imgName, int blockW, int blockH)
public static MMap loadFromRS(java.lang.String recName, java.lang.String imgName, int cellWidth, int cellHeight)
recName
- Name of the RecordStore where map data is storedimgName
- Filename of image used for cell tiles (pictures in the cells)cellWidth
- The width in pixels of each cellcellHeight
- The height in pixels of each cellpublic static MMap loadFromFile(java.lang.String filename, java.lang.String imgName, int cellWidth, int cellHeight)
filename
- resource file to load from, should be a binary fileimgName
- Filename of image used for cell tiles (pictures in the cells)cellWidth
- The width in pixels of each cellcellHeight
- The height in pixels of each cellpublic void updateBuffer(boolean clear)
clear
- Fills the background with clearColor.public javax.microedition.lcdui.Image getBuffer()
public void paint(javax.microedition.lcdui.Graphics g, int x, int y)
public int getCell(int number)
number
- Cellnumber, converted to x,y.public int getCellNumber(int cellX, int cellY)
public int getCellNumberAtPixel(int screenX, int screenY)
public int getPixelX(int number)
number
- Cellnumber, translated to x, y.public int getPixelY(int number)
number
- Cellnumber, translated to x, y.public void setCell(int number, int value)
number
- Cellnumber, translated into x, y.value
- Tilenumber.public void modifyCellValue(int number, int change)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |