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:
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...
Code: Select all
BodyDef bd = new BodyDef();
bd.position.set(0.0f, groundY/DodgePong.pxPerMeter);
bd.setType(BodyType.STATIC);
EdgeShape es = new EdgeShape();
es.setRadius(DodgePong.appgc.getWidth()/DodgePong.pxPerMeter);
FixtureDef fd = new FixtureDef();
fd.setShape(es);
fd.setFriction(0.5f);
Body ground = world.createBody(bd);
ground.createFixture(fd);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...