javaprocessingcollision-detectionphysics-enginejbox2d

Not able to use Contact class for collision in jBox2D using Processing


I am working on this project using jBox2D along with Processing(P3). While working on the collision handling, i am unable to use the "Contact" class, for getting the contact object and obtaining the fixtures.

The following is the basic structure of the code with only the necessary stuff.

import shiffman.box2d.*;
import org.jbox2d.collision.shapes.*;
import org.jbox2d.common.*;
import org.jbox2d.dynamics.*;

Box2DProcessing mainBox2D;

void setup(){
  fullScreen();
  mainBox2D = new Box2DProcessing(this);
  mainBox2D.createWorld();
  mainBox2D.listenForCollisions();
}

void draw(){
  mainBox2D.step();
}

void beginContact(Contact c){ //this is where i am getting the error 'The class "Contact" does not exist'
}

I am also getting some other stuff in the error description, the screenshot of which is below.

enter image description here

Thank you for taking your time on reading this and helping me out.


Solution

  • You're missing an import:

    import org.jbox2d.dynamics.contacts.*;
    

    Have fun!