无法在jBox2D中使用Contact类进行碰撞处理。

问题描述 投票:0回答:1

我正在使用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'
}

我在错误描述中还得到了一些其他的东西,其截图如下。

enter image description here

谢谢你花时间看完这篇文章并帮助我。

java processing collision-detection physics-engine jbox2d
1个回答
1
投票

你缺少一个导入。

import org.jbox2d.dynamics.contacts.*;

玩得开心点!

© www.soinside.com 2019 - 2024. All rights reserved.