我正在使用jBox2D和Processing(P3)来做这个项目。在处理碰撞时,我无法使用 "Contact "类来获取接触对象和获取夹具。
以下是代码的基本结构,只有必要的东西。
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'
}
我在错误描述中还得到了一些其他的东西,其截图如下。
谢谢你花时间看完这篇文章并帮助我。
你缺少一个导入。
import org.jbox2d.dynamics.contacts.*;
玩得开心点!