Box2D is an open-source rigid-body 2D physics simulation library for games, written in C++, with ports in various languages

learn more… | top users | synonyms

0
votes
2answers
705 views

Move Box2D body towards mouse click

In a top down game using Box2D, I would like the player's Box2D body to rotate towards the mouse click, and then move to a point on mouse click (move, not teleport). I have worked out the rotation ...
1
vote
1answer
52 views

Problems managing collision filtering

I have my character fixture and body(is a tank), so when I press the screen it throws a rocket(which also has a body and a fixture) that the player can controlll touching the screen. My game also has ...
0
votes
2answers
627 views

Libgdx box2d crashing

im making a game in libgdx which i having a bunch of circle bodies floating around in space and when the player's body crashes into another body, that body deletes and creates two smaller bodies ...
1
vote
1answer
1k views

libgdx sprite position relative to body

Apologies if this is a reiteration, as I couldn't find another discussion of this over the past couple days. Issue: I'm using libgdx and box2d, and I'm currently updating the sprite's position to ...
0
votes
2answers
36 views

How to create a linear plateform between two points?

I have a set of 2D coordinates. Their positions are regular on the X axis, but unpredictable on the Y axis: I would like to create slim platform between each point in order tu use it as ground for ...
4
votes
1answer
301 views

LibGDX Box2D TileGame Efficiency

I am trying to implement Box2D into my top down tile game in LibGDX. Each world consists of a set of chunks, and each chunk is 16 tiles wide/long. The maximum/minimum chunks loaded at one time is 9 (a ...
1
vote
1answer
223 views

Rotating towards a point in Box2D

I'm using Box2d as my physics engine and I'm trying to solve what would normally be a simple problem but what has become a nightmare for me and preventing me from finishing my app. (6 months work) ...
0
votes
1answer
39 views

How to split a screen in half using LibGDX without scaling?

I am currently working on a racing game with libGDX and I need to split the screen in half for a two-players mode. (Player 1 in first half and Player 2 in second half). I already have Camera1 that ...
0
votes
1answer
93 views

Black screen when launching on phone

I am coding a game in libgdx. While adding the background I used the html module to watch the results fast and easy on my computer. But when I try to see it on my phone I just get a black screen. My ...
3
votes
1answer
132 views

Creation of a tiled map editor polyline in box2d is not working correctly

I'm currently trying to create a box2d polyline object in my libgdx game, but it's not working as expected. To get a better picture of my subject, have a look at how it should look like, and how it ...
0
votes
1answer
51 views

How to unload/remove body components in Box2D?

I want to know how to release/clear/remove a variable. (specifically b2BodyDef, b2Body, b2FixtureDef, b2PolygonShape types.) I've heard there's a keyword called delete, guessing by it's name it may ...
0
votes
0answers
117 views

Box2dMapObjectParser isometric map - bodies have wrong position and size

I'm using Box2dMapObjectParser to load Tiled objects layer onto my IsometricTiledMapRenderer'ed TiledMap. It works OK with a UnitScale of 1 but the position is wrong and some shapes have weird ...
1
vote
1answer
56 views

How to handle two players playing on one keyboard with Box2D (LibGDX)?

I'm making a racing game with LibGDX and Box2D. I've been using this tutorial to implement the basic physics, and it works properly. My main problem is to implement two different sets of keys ...
1
vote
1answer
879 views

Changing Box2D Body from Kinematic to Dynamic after contact

What is the correct way to change a Kinematic body into a dynamic body? context - I have a dynamic body as a projectile which has to be fired at a kinematic body (it is kinematic because i am ...
2
votes
4answers
229 views

How to make sure that when two bodies collide, there is only one collision detection on box2d?

I'm using LibGDX with Box2D and, when two bodies collide, the collision is detected multiple times. Here's the code: public void preSolve(Contact contact, Manifold oldManifold) { Body a = ...
-1
votes
0answers
16 views

How to make the interaction of sensors is in box2d? [closed]

can not figure out how to make the interaction of the sensor platform has become active. something like this: BeginContact { if (sensorA && sensorB){ platform.getBody () ...
0
votes
1answer
165 views

How to convert pixels to meters in Box2d with Cocos2d-x 3.5?

I am using Cocos2d-x 3.5. I created a simple game with edge bodies and one circular body to test box2d. Physics wasn't working well, so i thought i should convert pixels to meters and use that meters ...
1
vote
1answer
41 views

Box2D fixed timestep updating is twitchy on constant FPS

I'm messing around with libgdx and box2d and I'm trying to implement sidescroller movement with fixed timestep logic according to the famous Fix Your Timestep! tutorial/guide. However, logic updating ...
2
votes
1answer
465 views

Wheel Joint Implementation in AndEngine

I am currently developing car game in AndEngine. In which I was using revolute joint for car wheel and chassis attachment. But my friend suggest me that use wheel joint for that purpose for better ...
1
vote
1answer
71 views

LibGDX Box2D texture on dynamic generated body

I'm creating a game that is similar to hill climb racing. I've generated the ground and now I want to add texture to the ground. Here is a screenshot of a game Here is my code (I create ground using ...
1
vote
0answers
33 views

Best way to create defence(withdraw) algorthim libgdx?

I have created user body and enemy body. Enemy body uses the steering behavior created by gdx AI. User body have it own control inputprocessor. World doesnt have gravity. Enemy body arrives the user ...
2
votes
1answer
362 views

LibGDX Box2D Lights - Illuminate background

I have a box2D world made of tiles. I use a custom DirectionalLight for light up the scene from above (It shines through transparent blocks [eg.: the water] more deeply). The problem is (as expected), ...
1
vote
1answer
625 views

Lighting shadow casting sprites with box2Dlights

I currently have something like this using box2Dlights Ideally, I would like objects casting shadows to be lit, so the object is lit but there is still a shadow cast around it. Right now the object ...
1
vote
1answer
1k views

Drawing Shape in DebugView (Farseer)

As the title says, I need to draw a shape/polygon in Farseer using debugview. I have this piece of code which converts a Texture to polygon: //load texture that will represent the tray ...
2
votes
3answers
310 views

Dynamic Hills like Contre Jour in Cocos2d

I'm interested in maps/environments which are flexible and change at runtime, such as those in Contre Jour. I have looked for a long time to find out how to make this effect, but I couldn't find an ...
0
votes
1answer
104 views

Set Position of multiple bodies

I have a character composed of five bodies which are tied together by a lot of joints. On of them is the overall chassis, to which all forces and impulses are applied to move the whole Character. All ...
0
votes
1answer
14 views

Box2dWeb: rotating object about a point

I am having problem rotating box2d object back and forth around a point. To better understand my problem i have prepared an example clicking on key rotate the paddle when u click again the paddle ...
0
votes
2answers
566 views

Libgdx using Box2d with TiledMap to create collision detection

I'm fairly new to Libgdx and have some good basic knowledge on Java. Right now I am stuck on how to add collision to my TiledMap, I am using the Mapeditor to create the tilemap. I read so many ...
0
votes
1answer
30 views

Libgdx + Box2d working with 2 cameras

Recently I have read that you can work with 2 cameras whenever you involve Box2d, which only works in meters. In my Renderer class, I receive all the entities in the game and then draw them. I work ...
0
votes
1answer
35 views

Libgdx Sprite rotation around specific point

I made complex dynamic body that rotates around other body that is static. It works perfectly, however I got messed up with sprite position on that body. Here's what I have now and here's what I ...
0
votes
0answers
46 views

Why is my tiled map moving when I move the camera in libGDX?

I use LibGDX. I have created a map with Tiled Map Editor and loaded it to the game. Everything else is working well, but when I move the camera, the map moves: it jumps or floats. My code: public ...
1
vote
0answers
30 views

Java Libgdx Attaching Sprite to Box2D Body

So I am working on programming a java 2D platformer for fun on the side and I have a rendered TMX level and a box2d body (just a circle shape) that I am currently using as my player. All the controls ...
0
votes
0answers
27 views

How can I simulate a basketball throw in LibGdx box2d?

So I want to simulate a similar throw like in the game Bouncy Basketball. Do i need to create a body and attach another body on it that would be the arm and then how would I apply force/impulse to the ...
0
votes
0answers
16 views

Box2d capsule stumbles on ground

I am working on a game with box2d and sdl. I Created a character and some boxes as ground, but faced the problem where the character would run a few meters, and stumble on one of the boxes' edge. I ...
0
votes
0answers
48 views

Box2D Physics Crazy

I have a simple Box2D Game with a dynamic player, a static floor, and a matrix of gems. The problem is that the physics engine goes crazy. You can see in this video: https://youtu.be/iaH_ex8eVVk ...
2
votes
2answers
114 views

Box2DLights in libGDX - Bad quality of the light gradient on Android

I am facing a problem while porting one of my libGDX project from desktop to Android : My game uses Box2DLights. While the light effect look very fancy on the desktop version of the game, it looks ...
0
votes
2answers
83 views

Why is my character passing through in Box2D?

I have a collision problem in Box2D. I am trying to do a simple platform game with Libgdx, Box2D and TiledMap. I have a map made with TiledMap: I load the map in my Android game. I read all the ...
0
votes
2answers
34 views

Sprite not drawn on the same position as its Body LibGDX after implementing Pixels Per Meter Division on Box2D

I had a problem where the sprite was not positioned on Body correctly which I solved and you can see it here: Box2D is not positioned on the sprite correctly LibGDX After I solved that, I needed to ...
0
votes
2answers
45 views

Box2D is not positioned on the sprite correctly LibGDX

I have a strange issue where my Box2D is not being positioned on the player correctly. Down is the picture: What I find more strange is that the Box2D is positioned correctly on the cloud that is ...
0
votes
1answer
37 views

LibGDX--constant high score in top corner

I'm currently programming a game using LibGDX and box2D. I have a sprite (player) that moves up the screen, kind of like doodle jump. I'd like to have my camera to be centered around the player at ...
0
votes
0answers
36 views

How to Implement a 2d camera object for a side scroller game

Ok so Heres the problem. I'm Using c++ with sfml for graphics and box2d for physics. I've tried an ultra simple cam movement in the past where i lock the player to the center of the screen and offset ...
0
votes
2answers
42 views

Libgdx box2d bodies go through other bodies

I'm developing a game using libGDX and box2d. I am facing a problem that bodies go through each other... I'm moving the body using a TouchPad by setTransform. I think the problem is that I use ...
1
vote
3answers
196 views

Box2d set sprite to body that rotates around specific point

I want to rotate kinematic body around a specific point (I already done this part using shape.setAsBox(1.8f / PPM, 0.2f / PPM, new Vector2(5.2f, 0), 0); What I try is this: PolygonShape shape ...
-1
votes
1answer
315 views

How to draw a curved line in Box2d?

I need to draw a curved line, I have searched the Internet but found nothing that would suit my needs. I used b2ChainShape but it's not completely what I need. How can I draw a curved line with ...
0
votes
1answer
469 views

libgdx - Box2d debug draw not correct

I have a problem where the bodies in my debug draw does not draw correctly, take a look: As you can see, there is some space between the dynamic body and the ground. I have checked the contact ...
0
votes
0answers
37 views

Box2D top down car weird spasm

im currently programming a 2d top down racing game with box2d and libgdx. i have a car body to which there are 4 wheels attached. these 4 wheels are attached with RevoluteJoints ( for the front ...
3
votes
1answer
62 views

Problem merging vertices of two polygonial bodies

SUMMARY I need help to create a weld joint that fixes the two bodies together in a way as illustrated in the first image. ISSUE I am having an issue where I cannot find out how to weld vertices of ...
2
votes
1answer
903 views

LibGDX - Box2D: Realistic Light and Layers

I'm having some problems with my current game. Short description: It's a 2D game where you have to avoid the lights or you lose HP. My problem is the following one: Here is the rendering process: ...
0
votes
0answers
68 views

Box2d - Texture lagging and flickering

I'm having issues with texture rendering in my game. I've done a lot of research and repeated the same steps of tutorials over the internet to render and update Sprite positions properly. Somehow, ...
0
votes
0answers
56 views

Libgdx and Box2D TiledMap render is not smooth

I'm building simple side scroller game. My player (square) move fast and it interacts with other world objects. Problem is when my player is moving it seems that all world is rendering somehow strange ...