Ground not working...

Discuss issues specific the Java port of Box2D
Posts: 1
Joined: Sat May 03, 2014 11:19 am

Ground not working...

Postby deavisdude » Sat May 03, 2014 11:28 am

So, I am new to box2d and game development in general, I have created a body for my character, which is working fine, but when I attempt to create the body for the ground it compiles, runs, but does not actually affect the player as he falls into oblivion. here is where I create the ground:

Code: Select all

BodyDef bd = new BodyDef();
      bd.position.set(0.0f, groundY/DodgePong.pxPerMeter);
      EdgeShape es = new EdgeShape();
      FixtureDef fd = new FixtureDef();
      Body ground = world.createBody(bd);

groundY is the pixel value of where the ground level is. Something is wrong with the position I think, because in the game loop I try to print out the position of the ground and just get a null pointer exception...

Return to “Java”

Who is online

Users browsing this forum: Google [Bot] and 2 guests