fisica
Class FContact

java.lang.Object
  extended by fisica.FContact

public class FContact
extends java.lang.Object

Represents a contact between two bodies. Objects of this type are not created by the users. Contacts are passed to the user when they implement the 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){ }.

See Also:
FContactResult

Method Summary
 FBody getBody1()
          Returns the first body involved in the contact.
 FBody getBody2()
          Returns the second body involved in the contact.
 float getNormalX()
          Returns the horizontal component of the contact normal.
 float getNormalY()
          Returns the vertical component of the contact normal.
 float getX()
          Returns the horizontal position of the contact point.
 float getY()
          Returns the vertical position of the contact point.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBody1

public FBody getBody1()
Returns the first body involved in the contact.

Returns:
first of the bodies involved in the contact

getBody2

public FBody getBody2()
Returns the second body involved in the contact.

Returns:
second of the bodies involved in the contact

getX

public float getX()
Returns the horizontal position of the contact point.

Returns:
the horizontal position of the contact point in pixels
See Also:
getY()

getY

public float getY()
Returns the vertical position of the contact point.

Returns:
the vertical position of the contact point in pixels
See Also:
getX()

getNormalX

public float getNormalX()
Returns the horizontal component of the contact normal.

Returns:
the horizontal component of the contact normal
See Also:
getNormalY()

getNormalY

public float getNormalY()
Returns the vertical component of the contact normal.

Returns:
the vertical component of the contact normal
See Also:
getNormalX()


processing library fisica by Ricard Marxer. (c) 2009-2011