New answers tagged

0

I recommend you look into how box2D works. Anyways use one of the below, most likely BeginContact. void BeginContact(b2Contact* contact); void EndContact(b2Contact* contact); Excerpt from the from the greatest source of Box2d knowledge know to mankind to explain why. iforce2d.com: Anatomy of a collision Impact 1, 2, 3 When fixtures are ...


0

As for X Y plane rotation, the formula is something like this: X = prevX * cos(θ) - prevY * sin(θ) Y = prevX * sin(θ) + prevY * cos(θ) But rotates around (0, 0) so if we want to rotate around (prevX, prevY) we have to substract the rotX and rotY first, where (rotX, rotY) is the center and (objX, objY) is the object, like this: prevX = objX - rotX ...


1

Ok, after 4 hours of searching finally I found the mistake. Problem was with the sprite origin. Here's the line that was necessary (staticBody is the body around other bodies will rotate) tmpSprite.setOrigin(staticBody.getPosition().x / 32 + tmpSprite.getWidth() / 2, staticBody.getPosition().y / 32 + tmpSprite.getHeight() / 2); And here's ...


0

Get vec2 from start point to target point (mouse coords in world space). Set b2body velocity to normalized version of that vec2, multiplied by your desired speed. Keep stepping - velocity will carry you closer to target point each time. On each step, if distance from current point to target point (magnitude) is less than velocity, set b2body position to the ...


1

Here is the solution : As Adam said in his answer, the problem was linked to a low bit depth on Android. If you look to the code of AndroidApplicationConfiguration.java, you'll notice at lines 30 and 31 this code : /** number of bits per color channel **/ public int r = 5, g = 6, b = 5, a = 0; Thus, Android applications with libGDX render, by default, ...


0

I have found the problem. TiledMAp is in Pixels. Box2D works in Meters. Scene2D works in Piexles I need to convert the Units between meters and Pixels.


0

This ended up fixing the problem: public void updatePlayer() { this.setPosition((body.getPosition().x) * GameInfo.PPM, (body.getPosition().y) * GameInfo.PPM); } Calling this in the render function and calling this in the render function: game.batch.draw(player, player.getX() - player.getWidth() / 2f, player.getY() - ...


1

In your createBody function: this.setPosition((body.getPosition().x),(body.getPosition().y)); Since the x and y position of the body is already divided by PPM you need to either multiply it by PPM again or remove this line completly because you already set the position in the constructor.



Top 50 recent answers are included