public class PositionComponent extends Component implements SerializableComponent, CopyableComponent<PositionComponent>
| Type | Property and Description |
|---|---|
javafx.beans.property.DoubleProperty |
x |
javafx.beans.property.DoubleProperty |
y |
| Constructor and Description |
|---|
PositionComponent()
Constructs a position component with x = y = 0.
|
PositionComponent(double x,
double y)
Constructs a position component from given x and y.
|
PositionComponent(javafx.geometry.Point2D position)
Constructs a position component from given point.
|
| Modifier and Type | Method and Description |
|---|---|
PositionComponent |
copy()
Copies this component.
|
double |
distance(PositionComponent other) |
int |
getGridX(int cellSize)
Note: if there is no bbox attached, entity is considered as a point,
else as a rectangle with the center placed in the cell.
|
int |
getGridY(int cellSize)
Note: if there is no bbox attached, entity is considered as a point,
else as a rectangle with the center placed in the cell.
|
javafx.geometry.Point2D |
getValue() |
double |
getX() |
double |
getY() |
void |
read(Bundle bundle) |
void |
setValue(double x,
double y)
Set position.
|
void |
setValue(javafx.geometry.Point2D position)
Set position.
|
void |
setX(double x)
Set x.
|
void |
setY(double y)
Set y.
|
String |
toString() |
void |
translate(double x,
double y)
Translate x and y by given values.
|
void |
translate(javafx.geometry.Point2D vector)
Translate x and y by given vector.
|
void |
translateTowards(javafx.geometry.Point2D position,
double distance) |
void |
translateX(double x)
Translate X by given value.
|
void |
translateY(double y)
Translate Y by given value.
|
void |
write(Bundle bundle) |
javafx.beans.property.DoubleProperty |
xProperty() |
javafx.beans.property.DoubleProperty |
yProperty() |
public javafx.beans.property.DoubleProperty xProperty
getX(),
setX(double)public javafx.beans.property.DoubleProperty yProperty
getY(),
setY(double)public PositionComponent(double x,
double y)
x - x coordinatey - y coordinatepublic PositionComponent(javafx.geometry.Point2D position)
position - pointpublic PositionComponent()
public double getX()
public javafx.beans.property.DoubleProperty xProperty()
getX(),
setX(double)public void setX(double x)
x - x coordinatepublic double getY()
public javafx.beans.property.DoubleProperty yProperty()
getY(),
setY(double)public void setY(double y)
y - y coordinatepublic javafx.geometry.Point2D getValue()
public void setValue(double x,
double y)
x - x coordinatey - y coordinatepublic void setValue(javafx.geometry.Point2D position)
position - positionpublic void translateX(double x)
x - dxpublic void translateY(double y)
y - dypublic void translate(double x,
double y)
x - dx valuey - dy valuepublic void translate(javafx.geometry.Point2D vector)
vector - translate vectorpublic void translateTowards(javafx.geometry.Point2D position,
double distance)
position - the point to move towardsdistance - the distance to movepublic double distance(PositionComponent other)
other - the other componentpublic int getGridX(int cellSize)
cellSize - size of each cell in the gridpublic int getGridY(int cellSize)
cellSize - size of each cell in the gridpublic void write(@NotNull
Bundle bundle)
public void read(@NotNull
Bundle bundle)
public PositionComponent copy()
CopyableComponentObject.clone().
The 'depth' of the copy should be determined by the user.copy in interface CopyableComponent<PositionComponent>Copyright © 2018. All rights reserved.