public class BoundingBoxComponent extends Component implements SerializableComponent, CopyableComponent<BoundingBoxComponent>
Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyDoubleProperty |
height |
javafx.collections.ObservableList<HitBox> |
hitBoxes |
javafx.beans.property.ReadOnlyDoubleProperty |
maxXWorld |
javafx.beans.property.ReadOnlyDoubleProperty |
maxYWorld |
javafx.beans.property.ReadOnlyDoubleProperty |
minXLocal |
javafx.beans.property.ReadOnlyDoubleProperty |
minXWorld |
javafx.beans.property.ReadOnlyDoubleProperty |
minYLocal |
javafx.beans.property.ReadOnlyDoubleProperty |
minYWorld |
javafx.beans.property.ReadOnlyDoubleProperty |
width |
Constructor and Description |
---|
BoundingBoxComponent(HitBox... boxes) |
Modifier and Type | Method and Description |
---|---|
void |
addHitBox(HitBox hitBox)
Add a hit (collision) bounding box.
|
CollisionResult |
checkCollision(BoundingBoxComponent other)
Checks for collision with another bounding box.
|
void |
clearHitBoxes()
Remove all hit boxes.
|
BoundingBoxComponent |
copy()
Copies this component.
|
javafx.geometry.Point2D |
getCenterLocal() |
javafx.geometry.Point2D |
getCenterWorld()
If entity doesn't have
PositionComponent then the center point
is the same as local center. |
double |
getHeight()
Returns total height of the bounding box, i.e.
|
double |
getMaxXLocal()
Note: same as width, unless specified otherwise.
|
double |
getMaxXWorld() |
double |
getMaxYLocal()
Note: same as height, unless specified otherwise.
|
double |
getMaxYWorld() |
double |
getMinXLocal() |
double |
getMinXWorld() |
double |
getMinYLocal() |
double |
getMinYWorld() |
double |
getWidth()
Returns total width of the bounding box, i.e.
|
javafx.beans.property.ReadOnlyDoubleProperty |
heightProperty() |
javafx.collections.ObservableList<HitBox> |
hitBoxesProperty() |
boolean |
isCollidingWith(BoundingBoxComponent other) |
boolean |
isOutside(double minX,
double minY,
double maxX,
double maxY) |
boolean |
isOutside(javafx.geometry.Rectangle2D bounds) |
boolean |
isWithin(double minX,
double minY,
double maxX,
double maxY) |
boolean |
isWithin(javafx.geometry.Rectangle2D bounds) |
javafx.beans.property.ReadOnlyDoubleProperty |
maxXWorldProperty() |
javafx.beans.property.ReadOnlyDoubleProperty |
maxYWorldProperty() |
javafx.beans.property.ReadOnlyDoubleProperty |
minXLocalProperty() |
javafx.beans.property.ReadOnlyDoubleProperty |
minXWorldProperty() |
javafx.beans.property.ReadOnlyDoubleProperty |
minYLocalProperty() |
javafx.beans.property.ReadOnlyDoubleProperty |
minYWorldProperty() |
void |
onAdded()
Called after the component is added to entity.
|
void |
onRemoved()
Called before the component is removed from entity.
|
javafx.geometry.Rectangle2D |
range(double width,
double height)
Forms a rectangle around the entity by extending min and max bounds
with width in X and with height in Y directions.
|
void |
read(Bundle bundle) |
void |
removeHitBox(String name)
Removes a hit box with given name from the list of hit boxes for this entity.
|
javafx.beans.property.ReadOnlyDoubleProperty |
widthProperty() |
void |
write(Bundle bundle) |
public final javafx.collections.ObservableList<HitBox> hitBoxesProperty
public javafx.beans.property.ReadOnlyDoubleProperty widthProperty
getWidth()
public javafx.beans.property.ReadOnlyDoubleProperty heightProperty
getHeight()
public javafx.beans.property.ReadOnlyDoubleProperty minXLocalProperty
getMinXLocal()
public javafx.beans.property.ReadOnlyDoubleProperty minYLocalProperty
getMinYLocal()
public javafx.beans.property.ReadOnlyDoubleProperty minXWorldProperty
getMinXWorld()
public javafx.beans.property.ReadOnlyDoubleProperty minYWorldProperty
getMinYWorld()
public javafx.beans.property.ReadOnlyDoubleProperty maxXWorldProperty
getMaxXWorld()
public javafx.beans.property.ReadOnlyDoubleProperty maxYWorldProperty
getMaxYWorld()
public BoundingBoxComponent(HitBox... boxes)
public void onAdded()
Component
public void onRemoved()
Component
public final javafx.collections.ObservableList<HitBox> hitBoxesProperty()
public final void addHitBox(HitBox hitBox)
hitBox
- the bounding boxpublic final void removeHitBox(String name)
name
- hit box namepublic final void clearHitBoxes()
public double getWidth()
public javafx.beans.property.ReadOnlyDoubleProperty widthProperty()
getWidth()
public double getHeight()
public javafx.beans.property.ReadOnlyDoubleProperty heightProperty()
getHeight()
public javafx.beans.property.ReadOnlyDoubleProperty minXLocalProperty()
getMinXLocal()
public double getMinXLocal()
public javafx.beans.property.ReadOnlyDoubleProperty minYLocalProperty()
getMinYLocal()
public double getMinYLocal()
public double getMaxXLocal()
public double getMaxYLocal()
public javafx.beans.property.ReadOnlyDoubleProperty minXWorldProperty()
getMinXWorld()
public javafx.beans.property.ReadOnlyDoubleProperty minYWorldProperty()
getMinYWorld()
public javafx.beans.property.ReadOnlyDoubleProperty maxXWorldProperty()
getMaxXWorld()
public double getMinXWorld()
public javafx.beans.property.ReadOnlyDoubleProperty maxYWorldProperty()
getMaxYWorld()
public double getMinYWorld()
public double getMaxXWorld()
public double getMaxYWorld()
public javafx.geometry.Point2D getCenterLocal()
public javafx.geometry.Point2D getCenterWorld()
PositionComponent
then the center point
is the same as local center.public final CollisionResult checkCollision(BoundingBoxComponent other)
CollisionResult.NO_COLLISION
will be returned.
If there is collision, the CollisionResult object must be put into pooler
after using the data.other
- bounding box to check collision againstpublic final boolean isCollidingWith(BoundingBoxComponent other)
other
- the other entitypublic final boolean isWithin(javafx.geometry.Rectangle2D bounds)
bounds
- a rectangular box that represents boundspublic final boolean isWithin(double minX, double minY, double maxX, double maxY)
minX
- min xminY
- min ymaxX
- max xmaxY
- max ypublic final boolean isOutside(javafx.geometry.Rectangle2D bounds)
bounds
- a rectangular box that represents boundspublic final boolean isOutside(double minX, double minY, double maxX, double maxY)
minX
- min xminY
- min ymaxX
- max xmaxY
- max ypublic final javafx.geometry.Rectangle2D range(double width, double height)
width
- width to extend by in each directionheight
- height to extend by in each directionpublic void write(@NotNull Bundle bundle)
public void read(@NotNull Bundle bundle)
public BoundingBoxComponent copy()
CopyableComponent
Object.clone()
.
The 'depth' of the copy should be determined by the user.copy
in interface CopyableComponent<BoundingBoxComponent>
Copyright © 2018. All rights reserved.