| java.lang.Object javax.microedition.lcdui.game.Layer
All known Subclasses: javax.microedition.lcdui.game.TiledLayer, javax.microedition.lcdui.game.Sprite,
Layer | abstract public class Layer (Code) | | A Layer is an abstract class representing a visual element of a game.
Each Layer has position (in terms of the upper-left corner of its visual
bounds), width, height, and can be made visible or invisible.
Layer subclasses must implement a
Layer.paint(Graphics) method so that
they can be rendered.
The Layer's (x,y) position is always interpreted relative to the coordinate
system of the Graphics object that is passed to the Layer's paint() method.
This coordinate system is referred to as the painter's coordinate
system. The initial location of a Layer is (0,0).
|
Field Summary | |
int | height | boolean | visible If the Layer is visible it will be drawn when paint
is called. | int | width | int | x | int | y |
Constructor Summary | |
| Layer(int width, int height) Creates a new Layer with the specified dimensions. |
Method Summary | |
final public int | getHeight() Gets the current height of this layer, in pixels. | final public int | getWidth() Gets the current width of this layer, in pixels. | final public int | getX() Gets the horizontal position of this Layer's upper-left corner
in the painter's coordinate system. | final public int | getY() Gets the vertical position of this Layer's upper-left corner
in the painter's coordinate system. | final public boolean | isVisible() Gets the visibility of this Layer. | public void | move(int dx, int dy) Moves this Layer by the specified horizontal and vertical distances. | abstract public void | paint(Graphics g) Paints this Layer if it is visible. | void | setHeightImpl(int height) Sets the current height of this layer, in pixels. | public void | setPosition(int x, int y) Sets this Layer's position such that its upper-left corner
is located at (x,y) in the painter's coordinate system. | public void | setVisible(boolean visible) Sets the visibility of this Layer. | void | setWidthImpl(int width) Sets the current width of this layer, in pixels. |
height | int height(Code) | | height of layer
|
visible | boolean visible(Code) | | If the Layer is visible it will be drawn when paint
is called.
|
width | int width(Code) | | width of layer
|
x | int x(Code) | | position of layer in x offset
|
y | int y(Code) | | position of layer in y offset
|
Layer | Layer(int width, int height)(Code) | | Creates a new Layer with the specified dimensions.
This constructor is declared package scope to
prevent developers from creating Layer subclasses
By default, a Layer is visible and its upper-left
corner is positioned at (0,0).
Parameters: width - The width of the layer, in pixels Parameters: height - The height of the layer, in pixels |
getHeight | final public int getHeight()(Code) | | Gets the current height of this layer, in pixels.
the height in pixels See Also: Layer.getWidth |
getWidth | final public int getWidth()(Code) | | Gets the current width of this layer, in pixels.
the width in pixels See Also: Layer.getHeight |
getX | final public int getX()(Code) | | Gets the horizontal position of this Layer's upper-left corner
in the painter's coordinate system.
the Layer's horizontal position. See Also: Layer.getY See Also: Layer.setPosition See Also: Layer.move |
getY | final public int getY()(Code) | | Gets the vertical position of this Layer's upper-left corner
in the painter's coordinate system.
the Layer's vertical position. See Also: Layer.getX See Also: Layer.setPosition See Also: Layer.move |
isVisible | final public boolean isVisible()(Code) | | Gets the visibility of this Layer.
true if the Layer is visible,false if it is invisible. See Also: Layer.setVisible |
move | public void move(int dx, int dy)(Code) | | Moves this Layer by the specified horizontal and vertical distances.
The Layer's coordinates are subject to wrapping if the passed
parameters will cause them to exceed beyond Integer.MAX_VALUE
or Integer.MIN_VALUE.
Parameters: dx - the distance to move along horizontal axis (positiveto the right, negative to the left) Parameters: dy - the distance to move along vertical axis (positivedown, negative up) See Also: Layer.setPosition See Also: Layer.getX See Also: Layer.getY |
paint | abstract public void paint(Graphics g)(Code) | | Paints this Layer if it is visible. The upper-left corner of the Layer
is rendered at it's current (x,y) position relative to the origin of
the provided Graphics object. Applications may make use of Graphics
clipping and translation to control where the Layer is rendered and to
limit the region that is rendered.
Implementations of this method are responsible for checking if this
Layer is visible; this method does nothing if the Layer is not
visible.
The attributes of the Graphics object (clip region, translation,
drawing color, etc.) are not modified as a result of calling this
method.
Parameters: g - the graphics object for rendering the Layer throws: NullPointerException - if g is null |
setPosition | public void setPosition(int x, int y)(Code) | | Sets this Layer's position such that its upper-left corner
is located at (x,y) in the painter's coordinate system.
A Layer is located at (0,0) by default.
Parameters: x - the horizontal position Parameters: y - the vertical position See Also: Layer.move See Also: Layer.getX See Also: Layer.getY |
setVisible | public void setVisible(boolean visible)(Code) | | Sets the visibility of this Layer. A visible Layer is rendered when
its
Layer.paint(Graphics) method is called; an invisible Layer is
not rendered.
Parameters: visible - true to make the Layer visible, false to make it invisible See Also: Layer.isVisible |
|
|