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
0answers
8 views

Apply force to center cap

I have a body and I'm applying force to it when the user is pressing the jumping button. I would like to stop when the body has reached an amount of "force". Tried to use body.getPosition but it ...
0
votes
0answers
5 views

Box2D - Slow movement on bodies when some are above others

I set a random position around the screen to some circle bodies with 1f density. And when some of them are above other bodies, they move until they dont touch each to other. I want this movement, but ...
0
votes
0answers
17 views

balloon ligher than air with libgdx, impementation of FixtureDef.density, gravityScale, linearDamping?

I use libGdx/box2d's physic. My intention is to create a balloon filled with helium (a body, what hovers above a surface, if we apply a little force to it - it moves fast but not far, if we push ...
0
votes
1answer
27 views

Marketing PC/Android 2d Physics Game

I've been working on a game for couple years now, its fairly original, has definite potential within an indie market, and appeal for the masses also. I want to deploy on Android and PC, green-light ...
0
votes
1answer
22 views

How do I query a LibGDX Box2DLights “light” and “dark” regions?

I have lighting implemented using Box2dLight. I want to update/render things inside the player's PointLight area. Stuff in the dark area should not be rendered. How can I find which areas are lit or ...
0
votes
0answers
19 views

Box2D collision between dynamic body

I'm implementing Box2D for my 2d top down LIBGDX game and i have some struggle with two dynamic body. Currently, my two bodies are created that way : BodyDef bodyDef = new BodyDef(); ...
0
votes
0answers
14 views

Box2D - Platformer tiled map problem

I'm using C++, Box2D and SFML. I convert a Tiled map to world in my platformer game and I get stuck when I go against a block when I go forward like that : I can use a circle as foot of my ...
0
votes
0answers
18 views

boost/geometry replacement in Java/for the JVM (Destructable Box2D terrain)

I'd like to reimplement https://github.com/seemk/DestructibleBox2D in Java. The main problem is finding an adequate replacement for the boost/geometry library. Any ideas?
0
votes
0answers
34 views

Smoothly move a Box2D body to target position

I am using java, LibGDX and Box2D. I could opt to move my player from the current position to a target position using the setPosition() method many times, in order for the body to move "smoothly" to ...
0
votes
1answer
7 views

Is GetFixtureA() of b2Contact guaranteed to return the body on which GetContactList() was called?

For example, in the code below, will the assert ever fail? for (const b2ContactEdge *contactEdge = playerPhysicsBody->GetContactList(); contactEdge; contactEdge = contactEdge->next) { ...
2
votes
1answer
33 views

Should I initialize a Box2D World per Level?

I'm using a LevelManager to load Tiled maps in my libGDX game, which stores: Static: final Size of map in Tiles final Size of map in Pixels final Size of an individual tile TiledMap ACTIVE_MAP ...
0
votes
0answers
17 views

Raycast trouble

i'm having some trouble with the RayCast. I'm raycasting from the player position and my mouse position. I have this situation : http://i.imgur.com/h7iplnY.png (the white line is a representation of ...
1
vote
1answer
28 views

Running and Jumping using Box2d and libgdx

.this is my first trial on making a 2d game and currently struglling how to run and jump smoothly. My problem is when the player keep pressing on left or right botton then jump. the player won't jump, ...
-1
votes
1answer
48 views

C++ SFML and Box2D: Move world or move player?

I'm currently making a top-down shooter game and it's my first time developing with SFML. I came across and issue and I want to know if there is a better way to solve it. I need to get the "camera" ...
2
votes
0answers
51 views

generate box2d bodies from isometric tiled map

I followed the tutorial here to generate box2d bodies from a tiled map and that worked fine.... for orthogonal tiled maps. Unfortunately isometric maps use their own coordinate system where (0, 0) is ...
1
vote
1answer
48 views

LOVE Physics - Joint Stretching

After asking a similar question yesterday I've come across another problem with using joints in box2D / LOVE and trying to create a weighted chain. Everything is set up as follows, I've tried to ...
1
vote
1answer
61 views

LOVE Physics - Breaking Joint Chains (LUA / Box2D)

Wasn't sure whether to post here or on SO so please move if needed. I've been having a look into the box2D physics API provided by LOVE to try and create a swinging flail or weighted rope but I'm ...
1
vote
2answers
58 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 to bodies collide collision is detected multiple times. here's the code `public void preSolve(Contact contact, Manifold oldManifold) { Body a = ...
0
votes
0answers
28 views

Which Box2D-like physics engine parameters need pixel conversion?

The official guide does not have any useful details on the matter: http://www.box2d.org/manual.html Position is an obvious one. What about velocity? Density? Anything else? Update: the context is ...
3
votes
1answer
67 views

Box2d Body to follow mouse movement

I am trying a box2d body to rotate following the mouse. Here's an image to clarify what I mean. The red and blue circles are current point of the mouse and the body (of corresponding color) ...
0
votes
1answer
53 views

Libgdx Scene2d and Box2d light

Currently I am using scene2d and I want to implement shadows using Box2d light. I want shadows under characters but when I draw something after render() , it draws nothing. For example, in draw() ...
1
vote
1answer
54 views

Box2D No Gravity when moving against wall

I use Box2D in my current project and I have a problem with the gravity.. You can see my problem here: https://www.youtube.com/watch?v=2_kv9LkKwN4&feature=youtu.be when i jump normal everything ...
2
votes
1answer
110 views

Creating a Melee Weapon in Box2D (libGDX)

I am struggling with how to implement a melee weapon that can swing when a key is pressed. I am imagining two different attacks (stab and swing) I have tried creating two fixtures (character + ...
0
votes
0answers
43 views

Use libgdx box2d for dynamically generated top down map

So, I've already found some information on how to use box2d and tiledmap together. Since I want to generate my top down map (100 by 100 tiles), I thought about only using box2d. The tiles would be ...
0
votes
0answers
31 views

LibGDX , Box2D body Mass Center

I am creating complex bodies using this editor. But the mass center of the body is not in the right place , when I apply force to it it begins rotating . So I am confused why is the masscenter in the ...
0
votes
0answers
20 views

Adapting qml-box2d to work with QGraphicsScene: transform origin is incorrect

I'm taking the convenient QObject wrappers from the Box2D QML Plugin and using them with a QGraphicsScene-based game. My motivation is to save time writing them myself, as I need to expose stuff to ...
0
votes
1answer
82 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 ...
1
vote
0answers
24 views

Sizing a Box2D ground object

I am developing a platformer game using SDL2 for graphics and Box2D for physics. I am currently designing my levels and would like to know if it is better to make the static part of each level (ie: ...
0
votes
0answers
30 views

LibGDX, Box2D , Destroy body into parts

I am developing a game using libGDX game engine and box2d physics engine. There are asteroids in my game, I want to destroy their bodies randomly and fill with texture. How can I do it?
0
votes
0answers
77 views

Why does physics interpolation give me periodic jumps/flickers?

I have seen this question but it didn't solve the problem. I have followed the same steps as in this article. What I notice in my Android game is that my interpolation alpha (or fraction or ...
0
votes
1answer
27 views

Box2d joints still attached after Explosion simulation

I ported simple Box2d Explosion simulation the function is called once when there is some event with the "Truck Car" the problem is that the Explosion working fine but it looks like when the explosion ...
1
vote
1answer
105 views

What are the steps for creating level in Libgdx with Box2d?

I have been trying to learn game programming for a week, although I have a good knowledge of programming. I don't understand some steps of game design. I'm recently working to clone the iSlash ...
0
votes
1answer
137 views

Good collision resolving mechanism

In my game i have plenty of objects that can collide. Literally, most of them can collide with each other.The problem I'm facing is that i can't come up with some good collision resolving way. How can ...
0
votes
1answer
64 views

Calculating density of an object

I'm using Box2D for physics in my game, and one of the things it needs to know when creating a shape for a physics body is the shape's density. I had no idea what value I should specify, so I went to ...
0
votes
1answer
77 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 ...
5
votes
2answers
104 views

Body lost a velocity component when hitting a wall

I am creating a Breakout game using Box2D (of LibGdx if anyone interest). Everything works well until when the ball hits the wall when moving with a very small angle. Please look at the image for ...
0
votes
1answer
49 views

box2d not centered in sprite [duplicate]

I am trying to create a bounding box for my sprite using box2d, but the box is being created at the wrong spot. I followed a tutorial on the wiki using this code BodyDef bodyDef1 = new BodyDef(); ...
1
vote
1answer
35 views

b2DistanceJoint with frequency equal to 0 vs b2WeldJoint

What is the difference of b2WeldJoint and b2DistanceJoint? They both have frequency and also when you put frequency of Distance Joint to 0 it acts like Weld Joint. It seams that you can create ...
0
votes
0answers
27 views

Setting Up the PTM_Ratio for Different Devices

I want to set the the physics for my Game and I have used Box2d for the Physics Simulation. And to do that I have set the PTM_Ratio to 32.0f.But When I run my Game on Different Android or iOS Devices ...
2
votes
1answer
85 views

In Box2D, how do I create an infinitely oscillating spring?

How do I create an ideal spring that can oscillate indefinitely using Box2D? A b2DistanceJoint works almost perfectly, but it eventually slows to a stop, even with damping set to 0. I think it is ...
1
vote
1answer
44 views

Checking if Body is surrounded by other Bodies

I'm trying to make a game like Rampart as practice. I have gotten to the point where I want to check if the castle is surrounded by walls and decide whether to fill in the area and continue the game, ...
0
votes
0answers
15 views

Box2d c++ can't see b2PolygonShape

i try to follow this tutorial and convert it to c++ http://www.emanueleferonato.com/2009/04/06/two-ways-to-make-box2d-cars/ the second part of the tutorial Now im facing very strange Behaviorno ...
1
vote
0answers
58 views

Calculate the rest length of a box2d distance joint

Given the length of a distance joint along with its frequency and the mass of the bodies involved, is it possible to determine the final rest length? I'm only interested in the vertical axis if that ...
1
vote
0answers
99 views

Using Box2D in LibGDX, is there a reason a fixture set to be a sensor would only -sometimes- detect a collision?

I am working on a 2D game in LibGDX. Currently, I am testing interactions between a player's weapon and enemies - in particular, a sword and an enemy monster. The player has a hurtbox and the sword ...
0
votes
0answers
35 views

Can't perform normal jump after applying revolute joint

I have encountered the following problem: I have two PolygonShapes which I had connected with a RevoluteJoint. The first body is called square the second is called weapon, before connecting the two ...
0
votes
1answer
142 views

My Raycast will not detect collisions in my Unity 2D project. What am I doing wrong?

I appreciate any help you can offer me. I created a script for a character controller that casts two rays below the player's gameobject. The rays extend infinitely and should collide with another ...
1
vote
1answer
121 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), ...
0
votes
0answers
40 views

Box2D replace Fixture not working as expected

I am using box2D to develop a simple game, and I am using the Physics body editor by Aurelien Ribon to load the fixtures into bodies. I have written the following method which should scale my ...
0
votes
0answers
32 views

Box2d :What is the best approach to build static Box2d smooth curve line [duplicate]

i want to know what is the best approach to simulate smooth curved line as static body it will be like path for car to drive . something like this : http://www.freeriderhd.com/ how does its box2d ...
0
votes
0answers
111 views

Preferred way to integrate box2d with SFML

I'm trying to integrate Box2D with sfml. My current solution is to have overloaded functions creating sfml shapes from box2d fixtureDef shapes. I store created sfml shapes under the name 'visual' in a ...