public class FContactResult extends Object
contactResult(FContactResult){ } method in the applet:
FWorld world;
void setup() {
Fisica.init(this);
world = new FWorld();
world.setEdges();
// Create and add bodies to the world here
// ...
}
void draw() {
world.step();
world.draw();
}
void contactResult(FContactResult result) {
// Draw an ellipse where the contact took place and as big as the normal impulse of the contact
ellipse(result.getX(), result.getY(), result.getNormalImpulse(), result.getNormalImpulse());
// Trigger your sound here
// ...
}
To know if the contact is the beggining, the continuation or the end of a contact it is better to use the other methods contactStarted(FContact){ }, contactPersisted(FContact){ } and contactEnded(FContact){ }.FContact| Modifier and Type | Field and Description |
|---|---|
protected FBody |
m_body1 |
protected FBody |
m_body2 |
protected fisica.FContactID |
m_id |
protected org.jbox2d.common.Vec2 |
m_normal |
protected float |
m_normalImpulse |
protected org.jbox2d.common.Vec2 |
m_position |
protected float |
m_tangentImpulse |
| Modifier | Constructor and Description |
|---|---|
protected |
FContactResult(org.jbox2d.dynamics.contacts.ContactResult contactResult) |
| Modifier and Type | Method and Description |
|---|---|
FBody |
getBody1()
Returns the first body involved in the contact.
|
FBody |
getBody2()
Returns the second body involved in the contact.
|
fisica.FContactID |
getId()
Get the identifier of the contact.
|
float |
getNormalImpulse()
Returns the normal component of the impulse of the contact.
|
float |
getNormalX()
Returns the horizontal component of the contact normal.
|
float |
getNormalY()
Returns the vertical component of the contact normal.
|
float |
getTangentImpulse()
Returns the tangential component of the impulse of the contact.
|
float |
getX()
Returns the horizontal position of the contact point.
|
float |
getY()
Returns the vertical position of the contact point.
|
protected org.jbox2d.common.Vec2 m_position
protected org.jbox2d.common.Vec2 m_normal
protected FBody m_body1
protected FBody m_body2
protected float m_normalImpulse
protected float m_tangentImpulse
protected fisica.FContactID m_id
protected FContactResult(org.jbox2d.dynamics.contacts.ContactResult contactResult)
public FBody getBody1()
public FBody getBody2()
public float getX()
getY()public float getY()
getX()public float getNormalX()
getNormalY()public float getNormalY()
getNormalX()public float getNormalImpulse()
getTangentImpulse()public float getTangentImpulse()
getNormalImpulse()public fisica.FContactID getId()