哪个.jar有JBox2d的p5包?

使用Eclipse,我试图编写一个简单的hello世界程序,只需在屏幕上绘制一个矩形,然后按照本教程中的说明将它放下。

问题是,当我尝试导入p5包时,它不能parsing,所以我不能声明我的物理对象。 我试了两件事。

  1. 下载zip,解压缩,然后导入3个jar(库,序列化和testing平台)

    一个。 import org.jbox2d.p5。*; 不解决,但其他人做

    湾 物理物理; 没有解决

  2. 下载较旧的独立testing平台的jar,然后导入它

    一个。 物理物理; 不解决;

这里基本上是我开始的地方

import org.jbox2d.util.nonconvex.*; import org.jbox2d.dynamics.contacts.*; import org.jbox2d.testbed.*; import org.jbox2d.collision.*; import org.jbox2d.common.*; import org.jbox2d.dynamics.joints.*; import org.jbox2d.p5.*; import org.jbox2d.dynamics.*; import processing.core.PApplet; public class MyFirstJBox2d extends PApplet { Physics physics; public void setup() { size(640,480); frameRate(60); initScene(); } public void draw() { background(0); if (keyPressed) { //Reset everything physics.destroy(); initScene(); } } public void initScene() { physics = new Physics(this, width, height); physics.setDensity(1.0f); physics.createRect(300,200,340,300); } } 

“物理”和p5包/类是jbox2d框架的扩展,这个家伙写道。 这似乎是相当不错,但不是我所做的。 我结束了这样做:

 import org.jbox2d.common.*; import org.jbox2d.dynamics.*; import org.jbox2d.collision.shapes.PolygonShape; import processing.core.PApplet; public class MyJBoxTest extends PApplet { private Vec2 gravity = new Vec2(0, -10f);; private World world; private Body floor; private Body player; private float fieldBottom = 300; private float timeStep = 1.0f / 60.f; private int velocityIterations = 6; private int positionIterations = 2; public void setup() { size(300, (int)fieldBottom); frameRate(60); background (0); world = new World(gravity); gameInit(); //simulateWorld(); } public void gameInit() { //Create Floor BodyDef aboutFloor = new BodyDef(); aboutFloor.position.set(0.0f, -8.0f); //-8 instead of -10 so I can see it PolygonShape groundBox = new PolygonShape(); groundBox.setAsBox(50.0f, 10.0f); // top lands at 0 aka floor floor = world.createBody(aboutFloor); floor.createFixture(groundBox, 0.0f); //Create Player BodyDef aboutPlayer = new BodyDef(); aboutPlayer.type = BodyType.DYNAMIC; //movable aboutPlayer.position.set(0.0f, 200.0f); PolygonShape playerBox = new PolygonShape(); playerBox.setAsBox(10.0f, 10.0f); FixtureDef fixtureDef = new FixtureDef(); fixtureDef.shape = playerBox; fixtureDef.density = 1.0f; fixtureDef.friction = 0.3f; player = world.createBody(aboutPlayer); player.createFixture(fixtureDef); } public void draw() { Vec2 floorLoc = floor.getPosition(); Vec2 playerLoc = player.getPosition(); background(0); rectMode(RADIUS); fill(255,0,0); rect(floorLoc.x, fieldBottom - floorLoc.y, 50, 10); rectMode(RADIUS); fill(255,100); rect (playerLoc.x, fieldBottom - playerLoc.y, 10, 10); world.step(timeStep, velocityIterations, positionIterations); } }