java.lang.Object | |
↳ | com.neomades.game.Layer |
![]() |
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 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).
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Layer() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int |
getHeight()
Gets the current height of this layer, in pixels.
| ||||||||||
Rect |
getRect()
Gets the bound of this Layer.
| ||||||||||
int |
getWidth()
Gets the current width of this layer, in pixels.
| ||||||||||
int |
getX()
Gets the horizontal position of this Layer's upper-left corner in the
painter's coordinate system.
| ||||||||||
int |
getY()
Gets the vertical position of this Layer's upper-left corner in the painter's
coordinate system.
| ||||||||||
boolean |
isVisible()
Gets the visibility of this Layer.
| ||||||||||
void |
move(int deltaX, int deltaY)
Moves this Layer by the specified horizontal and vertical distances.
| ||||||||||
abstract void |
paint(Graphics g)
Paints this Layer if it is visible.
| ||||||||||
void |
setPosition(Point point)
Sets this Layer's position such that its upper-left corner is located at
(x,y) in the painter's coordinate system.
| ||||||||||
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.
| ||||||||||
void |
setVisible(boolean visible)
Sets the visibility of this Layer.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Gets the current height of this layer, in pixels.
Gets the current width of this layer, in pixels.
Gets the horizontal position of this Layer's upper-left corner in the painter's coordinate system.
Gets the vertical position of this Layer's upper-left corner in the painter's coordinate system.
Gets the visibility of this Layer.
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.
deltaX | the distance to move along horizontal axis (positive to the right, negative to the left) |
---|---|
deltaY | the distance to move along vertical axis (positive down, negative up) |
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.
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.
point | the position |
---|
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.
Sets the visibility of this Layer.
visible | false to hide the layer |
---|