public abstract class FBody
extends java.lang.Object
Constructor and Description |
---|
FBody() |
Modifier and Type | Method and Description |
---|---|
void |
addForce(float fx,
float fy)
Aply a force on the center of the body.
|
void |
addForce(float fx,
float fy,
float px,
float py)
Apply a force to a given point of the body.
|
void |
addImpulse(float fx,
float fy)
Apply an impulse on the center of the body.
|
void |
addImpulse(float fx,
float fy,
float px,
float py)
Apply an impulse to a given point of the body.
|
void |
addTorque(float torque)
Add a rotation force (a torque) to the body.
|
void |
addToWorld(FWorld world) |
void |
adjustAngularVelocity(float dw)
Adjust the rotation velocity of the body.
|
void |
adjustPosition(float dx,
float dy)
Adjust the position of the body.
|
void |
adjustRotation(float dw)
Adjust the rotation of the body.
|
void |
adjustVelocity(float dvx,
float dvy)
Adjust the velocity of the body.
|
void |
attachImage(processing.core.PImage img)
Attach an image to the object.
|
void |
dettachImage()
Dettach any image that has been attached to the object.
|
void |
draw(processing.core.PApplet applet)
This method is called when calling
world.draw() . |
void |
draw(processing.core.PGraphics graphics)
This method is called when calling
world.draw() . |
void |
drawDebug(processing.core.PApplet applet)
This method is called when calling
world.drawDebug() . |
void |
drawDebug(processing.core.PGraphics graphics)
This method is called when calling
world.drawDebug() . |
float |
getAngularVelocity()
Returns the rotation velocity of the body.
|
org.jbox2d.dynamics.Body |
getBox2dBody()
WARNING: This method is internal only and may change someday.
|
int |
getCategoryBits() |
java.util.ArrayList |
getContacts()
Return a list of contacts currently involving the body.
|
float |
getDensity()
Get the density of the body.
|
int |
getFillColor()
Returns the fill color of the object.
|
int |
getFilterBits() |
float |
getForceX()
Get the x coordinate of the force applied to the center of the body.
|
float |
getForceY()
Get the y coordinate of the force applied to the center of the body.
|
int |
getGroupIndex()
Get the group to which this body belongs.
|
float |
getImageAlpha()
Get the opacity with which to draw the attached image.
|
java.util.ArrayList |
getJoints()
Returns a list with all the joints with a connection to the body
|
float |
getMass()
Returns the mass of the body.
|
java.lang.String |
getName()
Get the name of the body.
|
FBody |
getParent() |
float |
getRotation()
Returns the rotation of the body.
|
java.util.ArrayList |
getTouching()
Return a list of bodies currently touching the body.
|
float |
getVelocityX()
Returns the horizontal velocity of the body.
|
float |
getVelocityY()
Returns the vertical velocity of the body.
|
float |
getX()
Returns the horizontal position of the body.
|
float |
getY()
Returns the vertical position of the body.
|
boolean |
isConnected(FBody other)
Returns true if the body is joint to the body passed as argument
|
boolean |
isDrawable()
Get whether the object must be drawn or not.
|
boolean |
isResting()
Deprecated.
|
boolean |
isSensor()
Returns whether the body is a sensor.
|
boolean |
isSleeping()
Indicates whether the body is in a sleeping state.
|
boolean |
isStatic()
Returns whether the body is static.
|
boolean |
isTouchingBody(FBody b)
Return whether the body is currently touching the body passed as argument.
|
void |
recreateInWorld() |
void |
removeFromWorld() |
void |
resetForces()
Remove all the forces that are applied to the body.
|
void |
setAllowSleeping(boolean allowSleep)
Set whether the body can sleep.
|
void |
setAngularDamping(float damping)
Set the damping of the rotation movement of the body.
|
void |
setAngularVelocity(float w)
Set the rotation velocity of the body.
|
void |
setBullet(boolean value)
Set whether the body is a bullet.
|
void |
setCategoryBits(int mask) |
void |
setDamping(float damping)
Set the damping of the translation movement of the body.
|
void |
setDensity(float density)
Set the density of the body.
|
void |
setDrawable(boolean drawable)
Set whether the object must be drawn or not.
|
void |
setFill(float g)
Set the fill color of the object.
|
void |
setFill(float g,
float a)
Set the fill color of the object.
|
void |
setFill(float r,
float g,
float b)
Set the fill color of the object.
|
void |
setFill(float r,
float g,
float b,
float a)
Set the fill color of the object.
|
void |
setFillColor(int col)
Set the fill color of the object.
|
void |
setFilterBits(int mask) |
void |
setForce(float fx,
float fy)
Set the force applied to the center of the body.
|
void |
setFriction(float friction)
Set the friction of the body.
|
void |
setGrabbable(boolean value)
Control if this body can be grabbed by the mouse, when clicked on.
|
void |
setGroupIndex(int index)
Control the group to which this body belongs.
|
void |
setImageAlpha(float alpha)
Set the opacity with which to draw the attached image.
|
void |
setName(java.lang.String name)
Set the name of the body.
|
void |
setNoFill()
Set that the object must be drawn without fill.
|
void |
setNoStroke()
Set that the object must be drawn without stroke.
|
void |
setParent(FBody b) |
void |
setPosition(float x,
float y)
Set the position of the body.
|
void |
setRestitution(float restitution)
Set the restitution of the body.
|
void |
setRotatable(boolean rotatable)
Set whether the body can rotate.
|
void |
setRotation(float w)
Set the rotation of the body.
|
void |
setSensor(boolean value)
Set whether the body is a sensor.
|
void |
setState(FBody b) |
void |
setStateFromWorld() |
void |
setStatic(boolean value)
Set whether the body is static.
|
void |
setStaticBody(boolean value)
Set whether the body is static.
|
void |
setStroke(float g)
Set the stroke color of the object.
|
void |
setStroke(float g,
float a)
Set the stroke color of the object.
|
void |
setStroke(float r,
float g,
float b)
Set the stroke color of the object.
|
void |
setStroke(float r,
float g,
float b,
float a)
Set the stroke color of the object.
|
void |
setStrokeColor(int col)
Set the stroke color of the object.
|
void |
setStrokeWeight(float weight)
Set the stroke weight of the object.
|
void |
setVelocity(float vx,
float vy)
Set the velocity of the body.
|
void |
wakeUp()
Wake up the body from a sleeping state.
|
public org.jbox2d.dynamics.Body getBox2dBody()
public int getGroupIndex()
public void addToWorld(FWorld world)
public void setState(FBody b)
public void setStateFromWorld()
public void recreateInWorld()
public void removeFromWorld()
public void setGroupIndex(int index)
index
- the index of the grouppublic void setFilterBits(int mask)
public void setCategoryBits(int mask)
public int getCategoryBits()
public int getFilterBits()
public void setParent(FBody b)
public FBody getParent()
public void setGrabbable(boolean value)
value
- if true
and the world it belongs to is grabbable, then the body is grabbable by the mouseFWorld.setGrabbable(boolean)
public void setForce(float fx, float fy)
fx
- the x coordinate of the forcefy
- the y coordinate of the forceaddForce(float,float)
public float getForceX()
addForce(float,float)
,
getForceY()
public float getForceY()
addForce(float,float)
,
getForceX()
public void addTorque(float torque)
torque
- the value of the torqueaddForce(float,float)
,
addForce(float,float,float,float)
public void addForce(float fx, float fy)
fx
- the x coordinate of the forcefy
- the y coordinate of the forceaddTorque(float)
,
addForce(float,float,float,float)
public void addImpulse(float fx, float fy)
fx
- the x coordinate of the forcefy
- the y coordinate of the forceaddTorque(float)
,
addForce(float,float,float,float)
public void addForce(float fx, float fy, float px, float py)
fx
- the x coordinate of the forcefy
- the y coordinate of the forcepx
- the x position relative to the body's center, where to apply the forcepy
- the y position relative to the body's center, where to apply the forceaddTorque(float)
,
addImpulse(float,float,float,float)
public void addImpulse(float fx, float fy, float px, float py)
fx
- the x coordinate of the forcefy
- the y coordinate of the forcepx
- the x position relative to the body's center, where to apply the forcepy
- the y position relative to the body's center, where to apply the forceaddTorque(float)
,
addForce(float,float,float,float)
public void resetForces()
public float getVelocityX()
public float getVelocityY()
public void setVelocity(float vx, float vy)
vx
- the horizontal velocity of the body in pixels per secondvy
- the vertical velocity of the body in pixels per secondpublic void adjustVelocity(float dvx, float dvy)
dvx
- the horizontal velocity to be added to the body in pixels per seconddvy
- the vertical velocity to be added to the body in pixels per secondpublic float getX()
getY()
,
setPosition(float,float)
public float getY()
getX()
,
setPosition(float,float)
public void setPosition(float x, float y)
x
- the horizontal position of the body in pixelsy
- the vertical position of the body in pixelspublic void adjustPosition(float dx, float dy)
dx
- the horizontal position to be added to the body in pixelsdy
- the vertical position to be added to the body in pixelspublic float getRotation()
setRotation(float)
public void setRotation(float w)
w
- the rotation of the body in radiansgetRotation()
public void adjustRotation(float dw)
dw
- the rotation to be added to the body in radiansgetRotation()
,
setRotation(float)
public boolean isResting()
public boolean isSleeping()
wakeUp()
,
setAllowSleeping(boolean)
public void wakeUp()
isSleeping()
,
setAllowSleeping(boolean)
public float getAngularVelocity()
setAngularVelocity(float)
,
adjustAngularVelocity(float)
public void setAngularVelocity(float w)
w
- the rotation velocity of the body in radians per secondpublic void adjustAngularVelocity(float dw)
dw
- the rotation velocity to be added to the body in radians per secondgetAngularVelocity()
,
setAngularVelocity(float)
public void setAngularDamping(float damping)
damping
- the damping of the rotation movement of the bodysetDamping(float)
public void setDamping(float damping)
damping
- the damping of the translation movement of the bodysetAngularDamping(float)
public void setName(java.lang.String name)
name
- the name of the bodypublic java.lang.String getName()
public void setDensity(float density)
density
- the density of the bodypublic float getDensity()
public void setSensor(boolean value)
value
- if true
the body will be a sensor. It will not collide when enters contact with other bodiespublic boolean isSensor()
true
the body is a sensor. It will not collide when enters contact with other bodiespublic void setStaticBody(boolean value)
setPosition
or setRotation
.value
- if true
the body will be staticpublic void setStatic(boolean value)
setPosition
or setRotation
.value
- if true
the body will be staticpublic float getMass()
public boolean isStatic()
setPosition
or setRotation
.true
the body is staticpublic void setBullet(boolean value)
value
- if true
the body will be a bulletpublic void setRestitution(float restitution)
restitution
- a positive value. A value of 0 means no bounce after a collision, and a value of 1 means bounce with it's full speed from a collisionpublic void setFriction(float friction)
friction
- a positive value. A value of 0 means no friction and thus the body will not be slown down if no other forces are appliedpublic void setRotatable(boolean rotatable)
rotatable
- if true
the body will not rotatepublic void setAllowSleeping(boolean allowSleep)
allowSleep
- if true
the body will be able to sleeppublic java.util.ArrayList getTouching()
public java.util.ArrayList getContacts()
public java.util.ArrayList getJoints()
public boolean isConnected(FBody other)
other
- the other bodytrue
the body is connected to otherpublic boolean isTouchingBody(FBody b)
b
- the body for which we want to know if there is contacttrue
the body is touching bpublic void draw(processing.core.PGraphics graphics)
world.draw()
.
This method may be overriden to allow custom drawing of the object.graphics
- the graphics onto which the object must be drawn.public void draw(processing.core.PApplet applet)
world.draw()
.
This method may be overriden to allow custom drawing of the object.applet
- the applet onto which the object must be drawn.public void drawDebug(processing.core.PGraphics graphics)
world.drawDebug()
.
This method may be overriden to allow custom debug drawing of the object.graphics
- the graphics onto which the object must be drawn.public void drawDebug(processing.core.PApplet applet)
world.drawDebug()
.
This method may be overriden to allow custom debug drawing of the object.applet
- the applet onto which the object must be drawn.public void attachImage(processing.core.PImage img)
draw(PApplet)
method.img
- the PImage to attach to the object.public void dettachImage()
attachImage(PImage)
public float getImageAlpha()
attachImage(PImage)
,
setImageAlpha(float)
public void setImageAlpha(float alpha)
alpha
- the opacity, a value from 0.0 to 1.0 with which to draw the attached imageattachImage(PImage)
,
getImageAlpha()
public void setDrawable(boolean drawable)
drawable
- if true
the object will be drawn, else it will notisDrawable()
public boolean isDrawable()
true
the object will be drawn, else it will notsetDrawable(boolean)
public int getFillColor()
myBody.setFillColor(color(20,100,30,90));
setNoFill()
,
setFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setFillColor(int col)
setFill(float)
, setFill(float,float)
, setFill(float,float,float)
or setFill(float,float,float,float)
col
- a Processing color type. e.g. myBody.setFillColor(color(20,100,30,90));
setNoFill()
,
setFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setNoFill()
public void setFill(float g)
g
- gray valuesetFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setFill(float g, float a)
g
- gray valuea
- alpha (opacity) valuesetFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setFill(float r, float g, float b)
r
- red valueg
- green valueb
- blue valuesetFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setFill(float r, float g, float b, float a)
r
- red valueg
- green valueb
- blue valuea
- alpha (opacity) valuesetFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setStrokeColor(int col)
setStroke(float)
, setStroke(float,float)
, setStroke(float,float,float)
or setStroke(float,float,float,float)
col
- a Processing color type. e.g. myBody.setStrokeColor(color(20,100,30,90));
setNoStroke()
,
setStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setNoStroke()
public void setStroke(float g)
g
- gray valuesetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setStroke(float g, float a)
g
- gray valuea
- alpha (opacity) valuesetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setStroke(float r, float g, float b)
r
- red valueg
- green valueb
- blue valuesetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setStroke(float r, float g, float b, float a)
r
- red valueg
- green valueb
- blue valuea
- alpha (opacity) valuesetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setStrokeWeight(float weight)
weight
- weight value in pixelssetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
processing library fisica by Ricard Marxer. (c) 2009-2014