[EDIT] got it working. I copied the line from the other thread into the
render method.
**Original***
I can't get your class to work.
I've created a body, but I can't see any graphics when I run the app.
Here's my Main class:
Quote:
private Slick2DJBox2DDebugDraw debugDraw;
...
public void init(GameContainer container) throws SlickException {
universe = new Universe();
debugDraw = new Slick2DJBox2DDebugDraw(container);
debugDraw.setFlags(DebugDraw.e_shapeBit);
universe.world.jBoxWorld.setDebugDraw(debugDraw); // Where world is your JBox2D world
...
}
The only thing I have in the
update method, is the jBoxWorld step.
render method is empty
Quote:
for (int i = 0; i < 60; ++i) {
....jBoxWorld.step(timeStep, velocityIterations, positionIterations);
...
}
In the same update loop I debug the position of the body, and I can see that it really moves. So I created the body correctly into the jBoxWorld.
Here's how I create the body
Quote:
//body definition
BodyDef bd = new BodyDef();
bd.position.set(1, 1);
bd.type = BodyType.DYNAMIC;
//define shape of the body.
CircleShape cs = new CircleShape();
cs.m_radius = 5.5f;
//define fixture of the body.
FixtureDef fd = new FixtureDef();
fd.shape = cs;
fd.density = 0.5f;
fd.friction = 0.3f;
fd.restitution = 0.5f;
//create the body and add fixture to it
character = jBoxWorld.createBody(bd);
character.createFixture(fd);
I tried to debug your class with
System.out.println("!!!"); but I couldn't see any other class using the debug class in a loop. Should my
update or
render class be used for this somehow? Right now it looks like the class is not being used, even though I initialized everything correctly. The other possibility is that for some reason the rendering is done incorrectly. Does the class use 1:1 scale when rendering objects
(1 meter = 1 pixel)?