public class PhysicsComponent extends Component
| Constructor and Description |
|---|
PhysicsComponent() |
| Modifier and Type | Method and Description |
|---|---|
void |
applyAngularImpulse(float impulse)
Apply an angular impulse.
|
void |
applyBodyAngularImpulse(float impulse)
Apply an angular impulse.
|
void |
applyBodyForce(Vec2 force,
Vec2 point)
Apply a force at a world point.
|
void |
applyBodyForceToCenter(Vec2 force)
Apply a force to the center of mass.
|
void |
applyBodyLinearImpulse(Vec2 impulse,
Vec2 point,
boolean wake)
Apply an impulse at a point.
|
void |
applyBodyTorque(float torque)
Apply a torque.
|
void |
applyForce(javafx.geometry.Point2D force,
javafx.geometry.Point2D point)
Apply a force at a world point.
|
void |
applyForceToCenter(javafx.geometry.Point2D force)
Apply a force to the center of mass.
|
void |
applyLinearImpulse(javafx.geometry.Point2D impulse,
javafx.geometry.Point2D point,
boolean wake)
Apply an impulse at a point.
|
void |
applyTorque(float torque)
Apply a torque.
|
Body |
getBody() |
javafx.geometry.Point2D |
getLinearVelocity() |
double |
getVelocityX() |
double |
getVelocityY() |
boolean |
isGenerateGroundSensor() |
boolean |
isMoving() |
boolean |
isMovingX() |
boolean |
isMovingY() |
boolean |
isOnGround()
Note: only works when
setGenerateGroundSensor(boolean) was called with value true
before attaching entity to game world. |
boolean |
isRaycastIgnored() |
void |
setAngularVelocity(double velocity)
Set velocity (angle in deg) at which the entity will rotate per tick.
|
void |
setBodyDef(BodyDef def)
Set custom body definition to describe a generated
body for this physics entity.
|
void |
setBodyLinearVelocity(Vec2 vector)
Set linear velocity for a physics entity.
|
void |
setBodyType(BodyType type)
A convenience method to avoid setting body definition
if only a change of body type is required.
|
void |
setFixtureDef(FixtureDef def)
Set custom fixture definition to describe a generated
fixture for this physics entity.
|
void |
setGenerateGroundSensor(boolean generate)
Force this entity to create a ground sensor, so that
isOnGround() can be used. |
void |
setLinearVelocity(double x,
double y)
Set linear velocity for a physics entity.
|
void |
setLinearVelocity(javafx.geometry.Point2D vector)
Set linear velocity for a physics entity.
|
void |
setOnPhysicsInitialized(Runnable code)
Set a callback to run when this entity has been added to physics world.
|
void |
setRaycastIgnored(boolean b)
Set true to make raycast ignore this entity.
|
void |
setVelocityX(double x) |
void |
setVelocityY(double y) |
public boolean isOnGround()
setGenerateGroundSensor(boolean) was called with value true
before attaching entity to game world.public final Body getBody()
public void setOnPhysicsInitialized(Runnable code)
code - the code to runpublic void setGenerateGroundSensor(boolean generate)
isOnGround() can be used.generate - flagpublic boolean isGenerateGroundSensor()
public void setFixtureDef(FixtureDef def)
def - fixture definitionpublic void setBodyDef(BodyDef def)
def - body definitionpublic void setBodyType(BodyType type)
type - body typepublic boolean isMovingX()
public boolean isMovingY()
public boolean isMoving()
public void setLinearVelocity(javafx.geometry.Point2D vector)
Use this method to move a physics entity. Please note that the vector x and y are in pixels.
vector - x and y in pixelspublic void setLinearVelocity(double x,
double y)
Use this method to move a physics entity. Please note that x and y are in pixels.
x - and y in pixelspublic void setVelocityX(double x)
public void setVelocityY(double y)
public double getVelocityX()
public double getVelocityY()
public void setBodyLinearVelocity(Vec2 vector)
Similar to setLinearVelocity(Point2D) but
x and y of the argument are in meters.
vector - x and y in meterspublic javafx.geometry.Point2D getLinearVelocity()
public void setAngularVelocity(double velocity)
velocity - value in ~ degrees per tickpublic void applyLinearImpulse(javafx.geometry.Point2D impulse,
javafx.geometry.Point2D point,
boolean wake)
impulse - the world impulse vector (in pixel/sec)point - the world position of the point of application (in pixel)wake - if this impulse should wake up the bodypublic void applyBodyLinearImpulse(Vec2 impulse, Vec2 point, boolean wake)
impulse - the world impulse vector (in meter/sec)point - the world position of the point of application (in meter)wake - if this impulse should wake up the bodypublic void applyForce(javafx.geometry.Point2D force,
javafx.geometry.Point2D point)
force - the world force vector (in pixel/sec)point - the world position of the point of application (in pixel)public void applyBodyForce(Vec2 force, Vec2 point)
force - the world force vector (in meter/sec)point - the world position of the point of application (in meter)public void applyForceToCenter(javafx.geometry.Point2D force)
force - the world force vector (in pixel/sec)public void applyBodyForceToCenter(Vec2 force)
force - the world force vector (in meter/sec)public void applyAngularImpulse(float impulse)
impulse - the angular impulse (in pixel/sec)public void applyBodyAngularImpulse(float impulse)
impulse - the angular impulse (in meter/sec)public void applyTorque(float torque)
torque - the force (in pixel)public void applyBodyTorque(float torque)
torque - the force (in meter)public void setRaycastIgnored(boolean b)
b - raycast flagpublic boolean isRaycastIgnored()
Copyright © 2018. All rights reserved.