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

1
vote
1answer
26 views

How to avoid position increment by velocity multiplied by delta time even the body is not moving?

In the below image, the character texture is properly sync to body even moving on free space. In the below image, the character is moving downward. But the texture got a span or not sync properly, ...
2
votes
2answers
67 views

LibGDX game crash without errors (maybe AssetManager)

i have a problem with my game. It's a endless run shooter/platform made with LibGDX (Scene2d and box2D). I do tests with LG G2, LG G3, Galaxy s4, desktop and android emulator and i have no one ...
2
votes
1answer
94 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 ...
1
vote
1answer
115 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 ...
4
votes
0answers
135 views

How to correctly implement 'layered lighting' with Box2D-Lights

How does one only allow Box2D-Lights to affect one and only one OrthographicCamera. After researching, I found the following answer. This answer goes into detail about how to prevent one camera from ...
1
vote
1answer
686 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
65 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 ...
1
vote
0answers
12 views

LibGDX Compare color of Box2D objects on collision

I have two red balls and two yellow balls, which were created from a class Ball. The balls are box2d circles, with sprites attached. Is there a way in which I can check to see if two balls have ...
1
vote
0answers
25 views

Test for Box2D collisions between object being dragged and other objects

Goal: I am writing a prototype which has as many as 50 (Box2D) colored balls on the screen. I can drag any ball, and what I need to do is test whether the dragging ball has touched a ball of the same ...
4
votes
1answer
217 views

Ledge climb animation and movement (2d platformer)

Struggling to make a decision on the implementation of a ledge climb mechanic for a physics driven 2d platformer. What is the best way to go about this without it getting overly complex? So far I ...
0
votes
1answer
1k views

Box2D shape/fixture position vs. body position

I load my rectangular shapes from a simple Tiled level into libGDX and want to create a physics world out of it via Box2D and attach sprite assets for rendering. I get the tiled object layer and ...
0
votes
1answer
88 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
2answers
841 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 ...
4
votes
1answer
320 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 ...
2
votes
1answer
278 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) I'...
0
votes
2answers
166 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 ...
0
votes
1answer
64 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 ...
2
votes
1answer
1k 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 ...
3
votes
1answer
185 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 ...
1
vote
1answer
96 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 (UP-...
2
votes
1answer
481 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
132 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 ...
2
votes
1answer
446 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
0answers
482 views

box2d's ApplyForce works wrong after cocos2d-x's replaceScene

i'm practicing making a breakout game, using cocos2d-x 3.x and box2d, referencing here. i create a ball in the scene's init function and apply force. when ball hits bottom wall, if i touch screen ...
1
vote
3answers
100 views

Limit access to socket end point

I'm developing a multiplayer canvas game based on socket.io and box2d physics engine. Is there a way to limit connections to my socket endpoint and only allow connections from a specific domain? ...
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
2answers
77 views

Jump-through & drop-down platform

I'm creating platforms in my game where the player can: 1) Jump through them from the bottom and land on top of them 2) While on top of them, drop down through them I've been able to get #2 working ...
1
vote
1answer
27 views

How to distinguish between full/partially intersecting Collider2D?

I'm using Unity 5 to make 2D game. I have a screen (gray), arena (green) and player-controlled object (yellow) that can be moved across the screen with mouse before placement: There is no ...
0
votes
1answer
62 views

How to apply Buoyant force to a Box2d body?

I have been following a formula to calculate the buoyant force needed to apply to a dynamic body to be able to simulate water. Fb = ρgV Fb - is the buoyant force ρ - density of the liquid g - ...
0
votes
1answer
16 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 ...
1
vote
0answers
33 views

Different Box2D bodies act differently and unexpectedly with same mass

I have a box2d body which is simply a rectangle (the spaceship). This ship flies around, affected by the gravity of planets (static circle bodies) just fine. I have tried changing the ship fixture ...
1
vote
1answer
34 views

Joint based destructible physics (like Armadillo Run)

I've implemented a destructible terrain system like Worms before (where weapons create holes in the terrain), but for the game I'm designing I want something more like Armadillo Run: https://www....
1
vote
0answers
7 views

Game freezing when i create a body Box2D Libgdx

I'm implementing a Worms game using libGDX and Box2D and I'm having a problem I didn't have until recently. When a player shoots, it creates a bullet body and applies a force to it. I have a step ...
0
votes
2answers
185 views

2D Platformer: add ability to jump on top of other character

I want to add ability to jump onto a head of other character/player, but still be able to go through them horizontally. There is one useful tutorial about one-way platforms, but that approach doesn't ...
0
votes
0answers
26 views

libgdx box2d move object in bezier curv

I'm making a game and i need to move my game object in a bezier curv path i succeeded in doing it: //create Bezir curv .... path.valueAt(outMove, val); path.derivativeAt(...
2
votes
5answers
333 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 = contact....
0
votes
0answers
8 views

LibGDX Box2D Body shape transformation

In the following method my player Body is created: public static Body createPlayer (World world) { BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyDef.BodyType.DynamicBody; ...
0
votes
0answers
40 views

Decrease force in a zero gravity world

I have a world with zero gravity. On a mouse pressed I apply a force so things drive away from the mouse. The problem is now that they keep on flying. How can i make them stop? box2d.world....
0
votes
0answers
49 views

LibGDX works well on android 4 and very bad on android 5 and 6

I have a problem with my game. The game is made with libgdx, scene2d and box2d and it uses an AssetManager. I tested this app on all my devices and here it is the results: Galaxy S3, android 4 (...
2
votes
3answers
319 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 ...
4
votes
1answer
388 views

How do I simulate a trampoline?

I'm quite new to game development. I was pretty impressed with the elastic effect I saw in this flash game when the ball hits the trampolines and I'm wondering how to recreate it. I've done some ...
0
votes
0answers
37 views

Box2D + SDL - Weird body positions

I'm having a problem where either my sprite, or my body position is off. Here's a picture so you can see exactly what's going on : (The box has stopped on the picture, probably because it's colliding ...
1
vote
2answers
734 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
46 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 ...
1
vote
0answers
173 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 ...
0
votes
1answer
180 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
0answers
40 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 ...
0
votes
2answers
857 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
38 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 ...