|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfisica.FBody
public abstract class FBody
Represents a body in the world. A body is an object which may collide and react to forces in the world. The bodies have many properties such as density, velocity, position, etc... with which we can control their behavior. This class cannot be be instantiated, instead use one of the derived classes.
Constructor Summary | |
---|---|
FBody()
|
Method Summary | |
---|---|
void |
addForce(float fx,
float fy)
Add a force applied on the center of the body. |
void |
addForce(float fx,
float fy,
float px,
float py)
Add a force to applied to a given point of the body. |
void |
addTorque(float torque)
Add a rotation force (a torque) to the body. |
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)
|
void |
draw(processing.core.PGraphics applet)
This method is called when calling world.draw() . |
float |
getAngularVelocity()
Returns the rotation velocity of the body. |
java.util.ArrayList |
getContacts()
Return a list of contacts currently involving the body. |
int |
getGroupIndex()
|
float |
getImageAlpha()
Get the opacity with which to draw the attached image. |
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 |
isDrawable()
Get whether the object must be drawn or not. |
boolean |
isResting()
Indicates whether the body is in a resting state. |
boolean |
isSensor()
Returns whether the body is a sensor. |
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 |
resetForces()
Remove all the forces that are applied to the body. |
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 |
setNoFill()
Set that the object must be drawn without fill. |
void |
setNoStroke()
Set that the object must be drawn without stroke. |
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 |
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FBody()
Method Detail |
---|
public int getGroupIndex()
public void setGroupIndex(int index)
index
- the index of the grouppublic void setFilterBits(int mask)
public void setCategoryBits(int mask)
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 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 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)
,
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 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 setDensity(float density)
density
- the density of the bodypublic 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 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 java.util.ArrayList getTouching()
public java.util.ArrayList getContacts()
public boolean isTouchingBody(FBody b)
b
- the body for which we want to know if there is contact
true
the body is touching bpublic void draw(processing.core.PGraphics 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 draw(processing.core.PApplet applet)
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 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()
setFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
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()
setStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
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)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |