public class FContact
extends java.lang.Object
contactStarted(FContact){ }
, contactPersisted(FContact){ }
and contactEnded(FContact){ }
methods 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 contactStarted(FContact contact) {
// Draw in green an ellipse where the contact took place
fill(0, 170, 0);
ellipse(contact.getX(), contact.getY(), 20, 20);
}
void contactPersisted(FContact contact) {
// Draw in blue an ellipse where the contact took place
fill(0, 0, 170);
ellipse(contact.getX(), contact.getY(), 10, 10);
}
void contactStarted(FContact contact) {
// Draw in red an ellipse where the contact took place
fill(170, 0, 0);
ellipse(contact.getX(), result.getY(), 20, 20);
}
To know if the contact is the beggining, the continuation or the end of a contact it is better to use the other method contactResult(FContactResult){ }
.FContactResult
Modifier and Type | Method and Description |
---|---|
boolean |
contains(FBody n1)
Returns true if the contact contains the body.
|
boolean |
contains(FBody n1,
FBody n2)
Returns true if the contact contains the two bodies.
|
boolean |
contains(java.lang.String n1)
Returns true if the contact contains the body.
|
boolean |
contains(java.lang.String n1,
java.lang.String n2)
Returns true if the contact contains the two bodies.
|
FBody |
getBody1()
Returns the first body involved in the contact.
|
FBody |
getBody2()
Returns the second body involved in the contact.
|
float |
getFriction()
Get the friction coefficient of the contact.
|
fisica.FContactID |
getId()
Get the identifier of the contact.
|
float |
getNormalX()
Returns the horizontal component of the contact normal.
|
float |
getNormalY()
Returns the vertical component of the contact normal.
|
float |
getRestitution()
Get the restitution coefficient of the contact.
|
float |
getSeparation()
Get the separation between the bodies.
|
float |
getVelocityX()
Returns the horizontal component of the contact velocity.
|
float |
getVelocityY()
Returns the vertical component of the contact velocity.
|
float |
getX()
Returns the horizontal position of the contact point.
|
float |
getY()
Returns the vertical position of the contact point.
|
public FBody getBody1()
public FBody getBody2()
public float getX()
getY()
public float getY()
getX()
public float getVelocityX()
getVelocityY()
public float getVelocityY()
getVelocityX()
public float getNormalX()
getNormalY()
public float getNormalY()
getNormalX()
public float getSeparation()
public float getFriction()
public float getRestitution()
public fisica.FContactID getId()
public boolean contains(java.lang.String n1, java.lang.String n2)
n1
- the name of one of the bodiesn2
- the name of another one of the bodiesFBody.setName(java.lang.String)
public boolean contains(FBody n1, FBody n2)
n1
- one of the bodiesn2
- another one of the bodiespublic boolean contains(java.lang.String n1)
FBody.setName(java.lang.String)
public boolean contains(FBody n1)
processing library fisica by Ricard Marxer. (c) 2009-2014