public class Rectangle
extends java.lang.Object
Sprite
, TileMap
)
and for specifying area of an image to be drawn
(see Texture
).
Rectangles with width or height equal to 0 can be used to represent edges
(see Tile.edgeLeft
, etc.)Modifier and Type | Field and Description |
---|---|
(package private) double |
bottom
y-coordinate of bottom edge of rectangle
|
(package private) double |
height
height of rectangle
|
(package private) double |
left
x-coordinate of left edge of rectangle
|
(package private) double |
right
x-coordinate of right edge of rectangle
|
(package private) double |
top
y-coordinate of top edge of rectangle
|
(package private) double |
width
width of rectangle
|
Constructor and Description |
---|
Rectangle()
Initialize rectangle with all values set to 0.
|
Rectangle(double left,
double top,
double width,
double height)
Initialize rectangle data from coordinates of top-left corner and size.
|
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
contains(double x,
double y)
Determine if this rectangle contains the point (x,y).
|
(package private) Vector2 |
getMinTranslationVector(Rectangle other)
Assuming that this rectangle and other rectangle overlap,
calculate the minimum length vector required to translate this rectangle
so that there is no longer any overlap between them.
|
(package private) boolean |
overlaps(Rectangle other)
Determine if this rectangle overlaps with other rectangle.
|
(package private) void |
setValues(double left,
double top,
double width,
double height)
Update rectangle data from coordinates of top-left corner and size.
|
double left
double top
double width
double height
double right
double bottom
Rectangle()
Rectangle(double left, double top, double width, double height)
left
- x-coordinate of top-left corner (left edge) of rectangletop
- y-coordinate of top-left corner (top edge) of rectanglewidth
- width of rectangleheight
- height of rectanglevoid setValues(double left, double top, double width, double height)
left
- x-coordinate of top-left corner (left edge) of rectangletop
- y-coordinate of top-left corner (top edge) of rectanglewidth
- width of rectangleheight
- height of rectangleboolean overlaps(Rectangle other)
other
- rectangle to check for overlapVector2 getMinTranslationVector(Rectangle other)
other
- rectangle to translate away fromboolean contains(double x, double y)
x
- x-coordinate of pointy
- y-coordinate of point