public class FBlob extends FBody
vertex method in a similar way to FPoly:
{
@code
FBlob myBlob = new FBlob();
myBlob.vertex(40, 10);
myBlob.vertex(50, 20);
myBlob.vertex(60, 30);
myBlob.vertex(60, 40);
myBlob.vertex(50, 50);
myBlob.vertex(40, 60);
myBlob.vertex(30, 70);
myBlob.vertex(20, 60);
myBlob.vertex(10, 50);
myBlob.vertex(10, 40);
myBlob.vertex(20, 30);
myBlob.vertex(30, 20);
myBlob.vertex(40, 10);
world.add(myBlob);
}
or it may be initialized using the method setAsCircle to set the initial shape as a circle:
{
@code
FBlob myBlob = new FBlob();
myBlob.setAsCircle(40);
world.add(myBlob);
}
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_bullet |
protected float |
m_damping |
protected float |
m_density |
protected org.jbox2d.common.Vec2 |
m_force |
protected float |
m_frequency |
protected float |
m_friction |
protected FConstantVolumeJoint |
m_joint |
protected float |
m_restitution |
protected float |
m_torque |
protected ArrayList |
m_vertexBodies |
protected float |
m_vertexSize |
protected ArrayList |
m_vertices |
m_allowSleep, m_angle, m_angularDamping, m_angularVelocity, m_body, m_categoryBits, m_filterBits, m_grabbable, m_groupIndex, m_isSleeping, m_linearDamping, m_linearVelocity, m_name, m_parent, m_position, m_rotatable, m_sensor, m_shape, m_static, m_worldm_drawable, m_fill, m_fillColor, m_image, m_imageAlpha, m_mask, m_stroke, m_strokeColor, m_strokeWeight| Constructor and Description |
|---|
FBlob()
Constructs a blob body that can be added to a world.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addForce(float fx,
float fy)
Aply a force on the center of the body.
|
void |
addTorque(float t)
Add a rotation force (a torque) to the body.
|
void |
addToWorld(FWorld world) |
void |
addVertexBody(FBody b)
Adds a vertex body to the initial shape of the blob.
|
void |
attachImage(def.processing.core.PImage img)
Attach an image to the object.
|
void |
dettachImage()
Dettach any image that has been attached to the object.
|
ArrayList |
getVertexBodies()
Returns vertices of the blob.
|
float |
getVertexSize()
Returns the size of the circular vertices of the blob.
|
float |
getVertexX(int i)
Gets the x coordinate of the ith vertex of the initial shape of the blob.
|
float |
getVertexY(int i)
Gets the y coordinate of the ith vertex of the initial shape of the blob.
|
void |
removeFromWorld() |
void |
setAsCircle(float size)
Sets the initial shape of the blob to a circle.
|
void |
setAsCircle(float x,
float y,
float size)
Sets the initial shape of the blob to a circle.
|
void |
setAsCircle(float x,
float y,
float size,
int vertexCount)
Sets the initial shape of the blob to a circle.
|
void |
setAsCircle(float size,
int vertexCount)
Sets the initial shape of the blob to a circle.
|
void |
setBullet(boolean d)
Set whether the body is a bullet.
|
void |
setDamping(float damping)
Sets the damping of the springs used to maintain the volume defined by the
vertices constant.
|
void |
setDensity(float d)
Set the density of the body.
|
void |
setDrawable(boolean val)
Set whether the object must be drawn or not.
|
void |
setFillColor(int col)
Set the fill color of the object.
|
void |
setFrequency(float frequency)
Sets the frequency of the springs used to maintain the volume defined by the
vertices constant.
|
void |
setFriction(float d)
Set the friction 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 |
setRestitution(float d)
Set the restitution of the body.
|
void |
setStrokeColor(int col)
Set the stroke color of the object.
|
void |
setStrokeWeight(float col)
Set the stroke weight of the object.
|
void |
setVertexSize(float size)
Sets the size of the circular vertices of the blob.
|
void |
vertex(float x,
float y)
Adds a vertex to the initial shape of the blob.
|
addForce, addImpulse, addImpulse, adjustAngularVelocity, adjustPosition, adjustRotation, adjustVelocity, applyMatrix, getAABB, getAngularVelocity, getBB, getBodies, getBox2dBody, getCategoryBits, getContacts, getDensity, getFilterBits, getForceX, getForceY, getGroupIndex, getJoints, getLocalWorldPoint, getMass, getName, getParent, getProcessedShapeDef, getRotation, getShapeDef, getShapeDefs, getTouching, getTransformedShapeDef, getVelocityX, getVelocityY, getX, getY, isConnected, isResting, isSensor, isSleeping, isStatic, isTouchingBody, postDraw, postDrawDebug, preDraw, preDrawDebug, processBody, processShapeDef, recreateInWorld, resetForces, setAllowSleeping, setAngularDamping, setAngularVelocity, setCategoryBits, setFilterBits, setForce, setGrabbable, setGroupIndex, setName, setParent, setPosition, setPosition, setRotatable, setRotation, setSensor, setState, setStateFromWorld, setStatic, setStaticBody, setVelocity, updateMass, wakeUpappletFill, appletFillStroke, appletStroke, draw, drawDebug, drawImage, getFillColor, getImageAlpha, isDrawable, setFill, setFill, setFill, setFill, setImageAlpha, setStroke, setStroke, setStroke, setStroke, updateStyleprotected ArrayList m_vertices
protected ArrayList m_vertexBodies
protected float m_damping
protected float m_frequency
protected float m_vertexSize
protected org.jbox2d.common.Vec2 m_force
protected float m_torque
protected float m_density
protected float m_restitution
protected float m_friction
protected boolean m_bullet
protected FConstantVolumeJoint m_joint
public FBlob()
vertex or setAsCircle to define the initial
shape of the blob.public void addToWorld(FWorld world)
addToWorld in class FBodypublic void removeFromWorld()
removeFromWorld in class FBodypublic void addVertexBody(FBody b)
b - b the body to be addedpublic void vertex(float x,
float y)
x - x coordinate of the vertex to be addedy - y coordinate of the vertex to be addedpublic float getVertexX(int i)
i - index of the vertex to retrievepublic float getVertexY(int i)
i - index of the vertex to retrievepublic void setAsCircle(float x,
float y,
float size,
int vertexCount)
vertex. This method must be called before adding
the body to the world.x - x coordinate of the position of the circley - y coordinate of the position of the circlesize - size of the circlevertexCount - number of vertices of the circlepublic void setAsCircle(float x,
float y,
float size)
vertex. This method must be called before adding
the body to the world.x - x coordinate of the position of the circley - y coordinate of the position of the circlesize - size of the circlepublic void setAsCircle(float size)
vertex. This method must be called before adding
the body to the world.size - size of the circlepublic void setAsCircle(float size,
int vertexCount)
vertex. This method must be called before adding
the body to the world.size - size of the circlevertexCount - number of vertices of the circlepublic float getVertexSize()
public void setVertexSize(float size)
size - size of the circular vertices of the blobpublic ArrayList getVertexBodies()
public void setFrequency(float frequency)
frequency - the frequency of the springs of the constant volume jointpublic void setDamping(float damping)
setDamping in class FBodydamping - the damping of the springs of the constant volume jointFBody.setAngularDamping(float)public void addForce(float fx,
float fy)
FBodyaddForce in class FBodyfx - the x coordinate of the forcefy - the y coordinate of the forceFBody.addTorque(float),
FBody.addForce(float,float,float,float)public void addTorque(float t)
FBodyaddTorque in class FBodyt - the value of the torqueFBody.addForce(float,float),
FBody.addForce(float,float,float,float)public void setDensity(float d)
FBodysetDensity in class FBodyd - the density of the bodypublic void setFriction(float d)
FBodysetFriction in class FBodyd - 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 setRestitution(float d)
FBodysetRestitution in class FBodyd - 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 setBullet(boolean d)
FBodypublic void setNoStroke()
FDrawablepublic void setNoFill()
FDrawablesetNoFill in class FDrawableFDrawable.setFill(float),
FDrawable.setFill(float,float),
FDrawable.setFill(float,float,float),
FDrawable.setFill(float,float,float,float)public void setFillColor(int col)
FDrawableFDrawable.setFill(float), FDrawable.setFill(float,float), FDrawable.setFill(float,float,float) or FDrawable.setFill(float,float,float,float)setFillColor in class FDrawablecol - a Processing color type. e.g. myBody.setFillColor(color(20,100,30,90));FDrawable.setNoFill(),
FDrawable.setFill(float),
FDrawable.setFill(float,float),
FDrawable.setFill(float,float,float),
FDrawable.setFill(float,float,float,float)public void setStrokeColor(int col)
FDrawableFDrawable.setStroke(float), FDrawable.setStroke(float,float), FDrawable.setStroke(float,float,float) or FDrawable.setStroke(float,float,float,float)setStrokeColor in class FDrawablecol - a Processing color type. e.g. myBody.setStrokeColor(color(20,100,30,90));FDrawable.setNoStroke(),
FDrawable.setStroke(float),
FDrawable.setStroke(float,float),
FDrawable.setStroke(float,float,float),
FDrawable.setStroke(float,float,float,float)public void setStrokeWeight(float col)
FDrawablesetStrokeWeight in class FDrawablecol - weight value in pixelsFDrawable.setStroke(float),
FDrawable.setStroke(float,float),
FDrawable.setStroke(float,float,float),
FDrawable.setStroke(float,float,float,float)public void setDrawable(boolean val)
FDrawablesetDrawable in class FDrawableval - if true the object will be drawn, else it will notFDrawable.isDrawable()public void attachImage(def.processing.core.PImage img)
FDrawable#draw(PApplet) method.attachImage in class FDrawableimg - the PImage to attach to the object.public void dettachImage()
FDrawabledettachImage in class FDrawableFDrawable.attachImage(PImage)