public class PositionComponent extends AbstractComponent 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() |
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(com.almasb.fxgl.io.serialization.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 speed) |
void |
translateX(double x)
Translate X by given value.
|
void |
translateY(double y)
Translate Y by given value.
|
void |
write(com.almasb.fxgl.io.serialization.Bundle bundle) |
javafx.beans.property.DoubleProperty |
xProperty() |
javafx.beans.property.DoubleProperty |
yProperty() |
getEntity, onAdded, onRemovedpublic 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 speed)
position - the point to move towardsspeed - the speed at which 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
com.almasb.fxgl.io.serialization.Bundle bundle)
write in interface com.almasb.fxgl.io.serialization.SerializableTypepublic void read(@NotNull
com.almasb.fxgl.io.serialization.Bundle bundle)
read in interface com.almasb.fxgl.io.serialization.SerializableTypepublic PositionComponent copy()
copy in interface CopyableComponent<PositionComponent>Copyright © 2017. All rights reserved.