public abstract class AbstractPhysicsObject extends Object implements ContactListener, BodyInterface
PhysicsBox, PhysicsCircle,
PhysicsPolygon, PhysicsStaticBox and
PhysicsStaticCircle.| Modifier and Type | Field and Description |
|---|---|
protected Fixture |
f
The physical characteristics of the the object, such as friction etc...
|
String |
name
A name for the object
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPhysicsObject(Shape.Type t,
String name,
Vector2 position,
float width,
float height,
float density,
float restitution,
float friction,
boolean isDynamic)
Abstract constructor.
|
protected |
AbstractPhysicsObject(Shape.Type t,
String name,
Vector2 position,
float width,
float height,
float density,
float restitution,
float friction,
float angle,
boolean isDynamic)
Abstract constructor.
|
protected |
AbstractPhysicsObject(String name,
Vector2 position,
Vector2[] vertices,
float density,
float restitution,
float friction,
boolean isDynamic)
Abstract constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyBodyAngularImpulse(float impulse,
boolean wake) |
void |
applyBodyForce(float forceX,
float forceY,
float pointX,
float pointY,
boolean wake) |
void |
applyBodyForce(Vector2 force,
Vector2 point,
boolean wake) |
void |
applyBodyForceToCenter(float forceX,
float forceY,
boolean wake) |
void |
applyBodyForceToCenter(Vector2 force,
boolean wake) |
void |
applyBodyLinearImpulse(float impulseX,
float impulseY,
float pointX,
float pointY,
boolean wake) |
void |
applyBodyLinearImpulse(Vector2 impulse,
Vector2 point,
boolean wake) |
void |
applyBodyTorque(float torque,
boolean wake) |
void |
beginContact(Contact contact) |
void |
collision(AbstractPhysicsObject theOtherObject,
float energy)
A collision occurred between this object and another.
|
protected void |
createFixture(Shape s,
float density,
float restitution,
float friction)
Creates the fixture (collision information) attached to the object
|
void |
destroy()
Should be called to destroy a simulated object Warning, deletion will
happen at the next simulation step, not immediately
|
void |
enableCollisionListener()
Makes the object react on collisions
|
void |
endContact(Contact contact) |
Body |
getBody()
Convenience method for some special operations.
|
float |
getBodyAngle() |
float |
getBodyAngleDeg() |
float |
getBodyAngularDamping() |
float |
getBodyAngularVelocity() |
Array<Fixture> |
getBodyFixtureList() |
float |
getBodyGravityScale() |
float |
getBodyInertia() |
float |
getBodyLinearDamping() |
Vector2 |
getBodyLinearVelocity() |
Vector2 |
getBodyLinearVelocityFromLocalPoint(Vector2 v) |
Vector2 |
getBodyLinearVelocityFromWorldPoint(Vector2 v) |
Vector2 |
getBodyLinearVelocityPixels() |
Vector2 |
getBodyLocalCenter() |
Vector2 |
getBodyLocalPoint(Vector2 v) |
Vector2 |
getBodyLocalVector(Vector2 v) |
float |
getBodyMass() |
MassData |
getBodyMassData() |
Vector2 |
getBodyPosition()
Body method redefinition for meters / pixels.
|
float |
getBodyRadius() |
Transform |
getBodyTransform() |
World |
getBodyWorld() |
Vector2 |
getBodyWorldCenter() |
Vector2 |
getBodyWorldPoint(Vector2 v) |
Vector2 |
getBodyWorldVector(Vector2 v) |
boolean |
isBodyActive() |
boolean |
isBodyAwake() |
boolean |
isBodyBullet() |
boolean |
isBodyFixedRotation() |
boolean |
isBodySleepingAllowed() |
void |
postSolve(Contact contact,
ContactImpulse impulse) |
void |
preSolve(Contact contact,
Manifold oldManifold) |
void |
setBodyActive(boolean active) |
void |
setBodyAngularDamping(float damping) |
void |
setBodyAwake(boolean awake) |
void |
setBodyLinearDamping(float damping) |
void |
setBodyLinearVelocity(float vx,
float vy) |
void |
setBodyLinearVelocity(Vector2 v) |
void |
setCollisionGroup(int id)
Sets a collision group to all fixtures of an
AbstractPhysicsObject. |
void |
setSensor(boolean enable)
Set (or unset) sensor mode
|
public String name
protected Fixture f
protected AbstractPhysicsObject(Shape.Type t, String name, Vector2 position, float width, float height, float density, float restitution, float friction, boolean isDynamic)
protected AbstractPhysicsObject(String name, Vector2 position, Vector2[] vertices, float density, float restitution, float friction, boolean isDynamic)
protected AbstractPhysicsObject(Shape.Type t, String name, Vector2 position, float width, float height, float density, float restitution, float friction, float angle, boolean isDynamic)
protected void createFixture(Shape s, float density, float restitution, float friction)
s - The shape we want for collisiondensity - The density of the object, in kg/ms²restitution - For elastic collisionsfriction - Coulomb friction, does not work for circlespublic void destroy()
public void enableCollisionListener()
public void collision(AbstractPhysicsObject theOtherObject, float energy)
theOtherObject - the collides objectenergy - the collision energypublic void setCollisionGroup(int id)
AbstractPhysicsObject.
Collision groups let you specify an integral group index.
You can have all fixtures with the same group index
always collide (positive index) or never collide (negative index).
See http://www.aurelienribon.com/blog/2011/07/box2d-tutorial-collision-filtering/id - the identifier of the grouppublic void beginContact(Contact contact)
beginContact in interface ContactListenerpublic void endContact(Contact contact)
endContact in interface ContactListenerpublic void postSolve(Contact contact, ContactImpulse impulse)
postSolve in interface ContactListenerpublic void preSolve(Contact contact, Manifold oldManifold)
preSolve in interface ContactListenerpublic Vector2 getBodyPosition()
BodyInterface interface.getBodyPosition in interface BodyInterfacepublic Vector2 getBodyLocalCenter()
getBodyLocalCenter in interface BodyInterfacepublic float getBodyAngle()
getBodyAngle in interface BodyInterfacepublic float getBodyAngleDeg()
getBodyAngleDeg in interface BodyInterfacepublic float getBodyRadius()
getBodyRadius in interface BodyInterfaceUnsupportedOperationExceptionUnsupportedOperationExceptionpublic void applyBodyTorque(float torque,
boolean wake)
applyBodyTorque in interface BodyInterfacepublic float getBodyAngularDamping()
getBodyAngularDamping in interface BodyInterfacepublic void setBodyAngularDamping(float damping)
setBodyAngularDamping in interface BodyInterfacepublic float getBodyLinearDamping()
getBodyLinearDamping in interface BodyInterfacepublic void setBodyLinearDamping(float damping)
setBodyLinearDamping in interface BodyInterfacepublic Vector2 getBodyLinearVelocity()
getBodyLinearVelocity in interface BodyInterfacepublic void setBodyLinearVelocity(Vector2 v)
setBodyLinearVelocity in interface BodyInterfacepublic Vector2 getBodyLinearVelocityPixels()
public Vector2 getBodyLinearVelocityFromLocalPoint(Vector2 v)
getBodyLinearVelocityFromLocalPoint in interface BodyInterfacepublic Vector2 getBodyLinearVelocityFromWorldPoint(Vector2 v)
getBodyLinearVelocityFromWorldPoint in interface BodyInterfacepublic float getBodyAngularVelocity()
getBodyAngularVelocity in interface BodyInterfacepublic Array<Fixture> getBodyFixtureList()
getBodyFixtureList in interface BodyInterfacepublic float getBodyGravityScale()
getBodyGravityScale in interface BodyInterfacepublic float getBodyInertia()
getBodyInertia in interface BodyInterfacepublic Vector2 getBodyLocalPoint(Vector2 v)
getBodyLocalPoint in interface BodyInterfacepublic Vector2 getBodyLocalVector(Vector2 v)
getBodyLocalVector in interface BodyInterfacepublic float getBodyMass()
getBodyMass in interface BodyInterfacepublic MassData getBodyMassData()
getBodyMassData in interface BodyInterfacepublic Transform getBodyTransform()
getBodyTransform in interface BodyInterfacepublic World getBodyWorld()
getBodyWorld in interface BodyInterfacepublic Vector2 getBodyWorldCenter()
getBodyWorldCenter in interface BodyInterfacepublic Vector2 getBodyWorldPoint(Vector2 v)
getBodyWorldPoint in interface BodyInterfacepublic Vector2 getBodyWorldVector(Vector2 v)
getBodyWorldVector in interface BodyInterfacepublic boolean isBodyActive()
isBodyActive in interface BodyInterfacepublic void setBodyActive(boolean active)
setBodyActive in interface BodyInterfacepublic boolean isBodyAwake()
isBodyAwake in interface BodyInterfacepublic void setBodyAwake(boolean awake)
setBodyAwake in interface BodyInterfacepublic boolean isBodyBullet()
isBodyBullet in interface BodyInterfacepublic boolean isBodyFixedRotation()
isBodyFixedRotation in interface BodyInterfacepublic boolean isBodySleepingAllowed()
isBodySleepingAllowed in interface BodyInterfacepublic void setBodyLinearVelocity(float vx,
float vy)
setBodyLinearVelocity in interface BodyInterfacepublic void applyBodyAngularImpulse(float impulse,
boolean wake)
applyBodyAngularImpulse in interface BodyInterfacepublic void applyBodyForce(float forceX,
float forceY,
float pointX,
float pointY,
boolean wake)
applyBodyForce in interface BodyInterfacepublic void applyBodyForce(Vector2 force, Vector2 point, boolean wake)
applyBodyForce in interface BodyInterfacepublic void applyBodyForceToCenter(float forceX,
float forceY,
boolean wake)
applyBodyForceToCenter in interface BodyInterfacepublic void applyBodyForceToCenter(Vector2 force, boolean wake)
applyBodyForceToCenter in interface BodyInterfacepublic void applyBodyLinearImpulse(float impulseX,
float impulseY,
float pointX,
float pointY,
boolean wake)
applyBodyLinearImpulse in interface BodyInterfacepublic void applyBodyLinearImpulse(Vector2 impulse, Vector2 point, boolean wake)
applyBodyLinearImpulse in interface BodyInterfacepublic void setSensor(boolean enable)
enable - Set the body traversable, but still sensible to collisionspublic Body getBody()
Copyright © 2014-2016 gdx2d - https://github.com/hevs-isi/gdx2d