|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.alienfactory.javamappy.Layer
public class Layer
Represents one of the layers in a Map
. See
LayerViewer
for details on
rendering a Layer
to the screen.
Constructor Summary | |
---|---|
Layer(MapHeader mapHeader,
short[][] layerData,
Block[] blocks,
AnimBlock[] animBlocks)
|
|
Layer(Map map,
short[][] layerData)
Deprecated. use @link Layer#Layer(MapHeader, short[][], Block[], AnimBlock[]) instead |
Method Summary | |
---|---|
AnimBlock |
getAnimBlock(int blockX,
int blockY)
Returns the AnimBlock at the given block coordinates. |
AnimBlock[] |
getAnimBlocks()
Returns the AnimBlocks used by this Layer, as passed into the constructor. |
Block |
getBlock(int blockX,
int blockY)
Returns the Block at the given block coordinates. |
int |
getBlockIndex(int blockX,
int blockY)
Returns the Block index at the given coordinates. |
Block[] |
getBlocks()
Returns the Blocks used by this Layer, as passed into the constructor. |
int |
getBottomCollisionCoor(int pixelX,
int pixelY,
int width,
int height)
Starts at the top of the given rectangle and works its way down, checking the status of the collision flags on the way. |
int |
getCollisionAt(int x,
int y)
Performs a collision detection test at the given pixel coordinates using the Block 's collision flags. |
int |
getHeightInBlocks()
Returns the height of the layer, measured in blocks. |
int |
getHeightInPixels()
Returns the height of the layer, measured in pixels. |
short[][] |
getLayerData()
Returns the raw layer data as passed into the constructor. |
int |
getLeftCollisionCoor(int pixelX,
int pixelY,
int width,
int height)
Starts at the right of the given rectangle and works its way to the left, checking the status of the collision flags on the way. |
MapHeader |
getMapHeader()
Returns the MapHeader associated with this Layer. |
int |
getRightCollisionCoor(int pixelX,
int pixelY,
int width,
int height)
Starts at the left of the given rectangle and works its way to the right, checking the status of the collision flags on the way. |
int |
getTopCollisionCoor(int pixelX,
int pixelY,
int width,
int height)
Starts at the bottom of the given rectangle and works its way up, checking the status of the collision flags on the way. |
int |
getWidthInBlocks()
Returns the width of the layer, measured in blocks. |
int |
getWidthInPixels()
Returns the width of the layer, measured in pixels. |
boolean |
isAnimBlock(int blockX,
int blockY)
A helper method that checks if the block at the given coordinates is an AnimBlock . |
boolean |
isCollisionAt(int x,
int y)
Performs a collision detection test at the given pixel coordinates using the Block 's collision flags. |
void |
setBlockIndex(int blockX,
int blockY,
int blockIndex)
Replaces the block at the given coordinates. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Layer(Map map, short[][] layerData)
public Layer(MapHeader mapHeader, short[][] layerData, Block[] blocks, AnimBlock[] animBlocks)
Method Detail |
---|
public MapHeader getMapHeader()
MapHeader
associated with this Layer. This method
should not return null
.
public int getWidthInBlocks()
public int getHeightInBlocks()
public int getWidthInPixels()
public int getHeightInPixels()
public short[][] getLayerData()
public Block[] getBlocks()
public AnimBlock[] getAnimBlocks()
public int getBlockIndex(int blockX, int blockY) throws java.lang.IllegalArgumentException
Block
index at the given coordinates. Animation
Blocks have negative values.
java.lang.IllegalArgumentException
public void setBlockIndex(int blockX, int blockY, int blockIndex) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public Block getBlock(int blockX, int blockY) throws java.lang.IllegalArgumentException
Block
at the given block coordinates.
java.lang.IllegalArgumentException
public AnimBlock getAnimBlock(int blockX, int blockY) throws java.lang.IllegalArgumentException
AnimBlock
at the given block coordinates. AnimBlock
then an
IllegalArgumentException
is thrown.
java.lang.IllegalArgumentException
public boolean isAnimBlock(int blockX, int blockY) throws java.lang.IllegalArgumentException
AnimBlock
.
java.lang.IllegalArgumentException
public boolean isCollisionAt(int x, int y)
Block
's collision flags.
x
- the X coordinatey
- the Y coordinate
true
if there is a collision flag set at the given
coordinatesBlock.setCollisionFlag(int, boolean)
,
Block.getCollisionFlag(int)
public int getCollisionAt(int x, int y)
Block
's collision flags. This method returns a
number representing which corner of the Block the coordinates collided
with, or -1 if no collision occurred.
x
- the X coordinatey
- the Y coordinate
Block.LEFT
, Block.RIGHT
,
Block.TOP
and Block.BOTTOM
or -1
if no collision occurredBlock.setCollisionFlag(int, boolean)
,
Block.getCollisionFlag(int)
public int getTopCollisionCoor(int pixelX, int pixelY, int width, int height)
public int getBottomCollisionCoor(int pixelX, int pixelY, int width, int height)
public int getLeftCollisionCoor(int pixelX, int pixelY, int width, int height)
public int getRightCollisionCoor(int pixelX, int pixelY, int width, int height)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |