New answers tagged

1

Problem solved: the error was in drawing the boxes all along. The way Box2D returns positions is by returning the center of an object, and not the upper-left corner. So all I had to do was deduct half the width and height from my texture's position to draw it in the right spot. m_bounds.x = m_body->GetPosition().x * World::PPM; m_bounds.y = ...


0

To me its looks like every thing is working fine. But the child which is holding the box "BoxCollider2D" is off the center So you need to take one more step to find the the mid point of the laser and then assign it to the child which holds "BoxCollider2D". Formula for finding mid point is: (vector1 + vector2)/2 vector 1, is start point of the laser. ...


0

Possible memory leak. LibGDX uses native Box2D. To use it, they wrote Java wrapper, because of that, the objects that are created by the native methods need manual disposal. FixtureDef fixtureDef = new FixtureDef(); fixtureDef.shape = shape; fixtureDef.density = 1f; Fixture fixture = body.createFixture(fixtureDef); shape.dispose(); // ...


Top 50 recent answers are included