java - LibGDX Box2D: Cannot get Fixture to render -


i have been trying libgdx's version of box2d, , looked @ demo created few months back, , code looks fine, , google search results, code fine, life of me, cannot fixture render.

here (minimalist example) code, , life of me, cannot work note: built wrapper around libgdx game class, should self-explanatory:

public class testbox2d extends eggame {      int width;     int height;      static final vector2 zero_gravity = new vector2(0f, 0f);      orthographiccamera camera;     world world;     body body;     box2ddebugrenderer box2ddebugrenderer;     rayhandler rayhandler;      ... // removed constructor, nothing special here.      @override     protected void init() {         width = gdx.graphics.getwidth() / 2;         height = gdx.graphics.getheight() / 2;         camera = new orthographiccamera(width, height);         camera.position.set(width / 2, height / 2, 0);         camera.update();          world = new world(zero_gravity, true);         box2ddebugrenderer = new box2ddebugrenderer();         rayhandler = new rayhandler(world);         rayhandler.setcombinedmatrix(camera.combined);          // creating body         bodydef bodydef = new bodydef();         bodydef.type = bodydef.bodytype.staticbody;         bodydef.position.set(width/2, height/2);          body = world.createbody(bodydef);          circleshape shape = new circleshape();         shape.setradius(1f);          fixturedef fixturedef = new fixturedef();         fixturedef.shape = shape;         body.createfixture(fixturedef);      }      @override     protected void updategame() {         world.step(1f / 30f, 6, 2);         rayhandler.update();     }      @override     protected void rendergame() {         box2ddebugrenderer.render(world, camera.combined);         rayhandler.render();     }      @override     public void dispose() {         world.dispose();     }      ... // removed main method, nothing special here. } 

note world.getbodycount(); , world.getfixturecount(); both return 1.

probable causes of problem.

  1. check if have called render on fixtures in either rayhandler class or box2ddebugrenderer class.

  2. you have not set position of circle shape. might lying on edge , remain out of camera bounds.

  3. check units. radius of circle might relatively small invisible, or might large might covering entire screen.

hope helps.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -