public final class HitBox extends Object implements Serializable
| Constructor and Description |
|---|
HitBox(BoundingShape shape)
Creates a hit box with the given shape.
|
HitBox(javafx.geometry.Point2D localOrigin,
BoundingShape shape)
Creates a hit box with the given local origin and shape.
|
HitBox(String name,
BoundingShape shape)
Creates a hit box with given name and shape.
|
HitBox(String name,
javafx.geometry.Point2D localOrigin,
BoundingShape shape)
Creates a hit box with given name, local origin (top-left) and shape.
|
| Modifier and Type | Method and Description |
|---|---|
void |
bindX(javafx.beans.property.DoubleProperty xProperty)
Bind to x property of entity.
|
void |
bindY(javafx.beans.property.DoubleProperty yProperty)
Bind to y property of entity.
|
javafx.geometry.Point2D |
centerLocal() |
javafx.geometry.Point2D |
centerWorld(double x,
double y) |
HitBox |
copy() |
javafx.geometry.Bounds |
getBounds() |
double |
getHeight() |
double |
getMaxX() |
double |
getMaxXWorld() |
double |
getMaxY() |
double |
getMaxYWorld() |
double |
getMinX() |
double |
getMinXWorld() |
double |
getMinY() |
double |
getMinYWorld() |
String |
getName() |
BoundingShape |
getShape() |
double |
getWidth() |
javafx.geometry.Bounds |
translate(double x,
double y)
Computes new bounds based on translated X and Y
of an entity.
|
javafx.geometry.Bounds |
translateXFlipped(double x,
double y,
double entityWidth)
Computes new bounds based on translated X and Y
of an entity with X axis being flipped.
|
void |
unbind()
Unbind the hit box.
|
public HitBox(BoundingShape shape)
{@link HitBox} will be auto generated
based upon the hashCode of the given {@link BoundingShape}.shape - bounding shapepublic HitBox(javafx.geometry.Point2D localOrigin,
BoundingShape shape)
{@link HitBox} will be auto generated
based upon the hashCode of the given {@link BoundingShape}.localOrigin - origin of hit boxshape - bounding shapepublic HitBox(String name, BoundingShape shape)
name - name of the hit boxshape - bounding shapepublic HitBox(String name, javafx.geometry.Point2D localOrigin, BoundingShape shape)
name - name of the hit boxlocalOrigin - origin of hit boxshape - bounding shapepublic javafx.geometry.Bounds translate(double x,
double y)
x - entity xy - entity ypublic javafx.geometry.Bounds translateXFlipped(double x,
double y,
double entityWidth)
x - entity xy - entity yentityWidth - entity widthpublic javafx.geometry.Bounds getBounds()
public BoundingShape getShape()
public double getMinX()
public double getMinY()
public double getMaxX()
public double getMaxY()
public double getWidth()
public double getHeight()
public String getName()
public void bindX(javafx.beans.property.DoubleProperty xProperty)
xProperty - x propertypublic void bindY(javafx.beans.property.DoubleProperty yProperty)
yProperty - y propertypublic void unbind()
public double getMinXWorld()
public double getMaxXWorld()
public double getMinYWorld()
public double getMaxYWorld()
public javafx.geometry.Point2D centerLocal()
public javafx.geometry.Point2D centerWorld(double x,
double y)
x - position x of entityy - position y of entitypublic HitBox copy()
Copyright © 2017. All rights reserved.