Questions tagged [box2d]

Box2D is a free open source 2-dimensional physics simulator engine written in C++ by Erin Catto and published under the zlib license

Box2D is a free open source 2-dimensional physics simulator engine written in C++ by Erin Catto and published under the zlib license.

The engine performs constrained rigid body simulation. It can simulate bodies composed of convex polygons, circles, and edge shapes. Bodies are joined together with joints and acted upon by forces. The engine also applies gravity, friction, and restitution.

Ports of Box2D exist for Java, ActionScript, C#, JavaScript, and D.

3289 questions
10
votes
2 answers

Box2d: mousejoint without inertial delay

I'm using mousejoint to drag bodies in box2d, but it causes inertial delay. Does it exist any way to drag a body instantaneously?
Ricibald
  • 9,369
  • 7
  • 47
  • 62
10
votes
3 answers

Position resizable circles near each other

I am working on this browser-based experiment where i am given N specific circles (let's say they have a unique picture in them) and need to position them together, leaving as little space between them as possible. It doesn't have to be arranged in…
user151496
  • 1,849
  • 24
  • 38
10
votes
1 answer

Extract X and Y Coordinates from String

I'm having a problem with extracting b2vec2 coordinates from a CCString these are from cocos2dx and box2d. I have tried using strtk but i could not get it to work Any help would be great. Thanks The Layout of the string is "x,y x,y x,y" i want to…
user1523362
  • 119
  • 9
10
votes
3 answers

Android, libgdx and box2d basics

I wrote couple of simple board games since i started on android learning, Please let me know is there any tutorial or links, where i can start with physics library with libgdx, looking for something like basics of physics with libgdx
Yogesh
  • 1,206
  • 4
  • 22
  • 50
9
votes
2 answers

Simulating water resistance in Box2D

I'm making a game where player drags a boat around using finger. I'm using Box2D for the physics aspects of the game. In particular, I'm using b2MouseJoint to attach the touch event to the boat to let the touch event drag the boat. But there is one…
Lukman
  • 18,462
  • 6
  • 56
  • 66
9
votes
1 answer

Disadvantages of sleeping bodies in Box2D

When creating a world in Box2D you have the option to enable bodies to sleep (no simulation is done on them if they come to rest). Why isn't sleeping the default option? What disadvantages does it have?
Paul Manta
  • 30,618
  • 31
  • 128
  • 208
9
votes
3 answers

Simulate "Newton's law of universal gravitation" using Box2D

I want to simulate Newton's law of universal gravitation using Box2D. I went through the manual but couldn't find a way to do this. Basically what I want to do is place several objects in space (zero gravity) and simulate the movement. Any tips?
Ashika Umanga Umagiliya
  • 8,988
  • 28
  • 102
  • 185
9
votes
1 answer

Libgdx Tiled map object to box2d body location

A Tiled map object hat a position x, y in pixels and a rotation in degrees. I am loading the coordinates and the rotation from the map and trying to assign them to a box2d Body. There are a couple of differences between the location models, for…
Aleris
  • 7,981
  • 3
  • 36
  • 42
9
votes
4 answers

Non-Rigid Body 2D Physics Engines in C++

I'm trying to experiment with 2D physics engines in C++. So far, it seems the most popular is Box2D. Unfortunately, Box2D is a rigid body physics engine and that's not really going to help me with what I want to try. I want to be able to define a…
Joseph Mansfield
  • 108,238
  • 20
  • 242
  • 324
9
votes
5 answers

physics game programming box2d - orientating a turret-like object using torques

This is a problem I hit when trying to implement a game using the LÖVE engine, which covers box2d with Lua scripting. The objective is simple: A turret-like object (seen from the top, on a 2D environment) needs to orientate itself so it points to a…
kikito
  • 51,734
  • 32
  • 149
  • 189
9
votes
2 answers

Create Water In Libgdx

I am develooping a game in libgdx with box2d. I spent hours of searching for a tutorial or somthing that explain how to create water in libgdx with box2d. I can't find how to do this. If somone have an idea it will very help me. How to create water…
user3421416
9
votes
3 answers

How to check if two Box2d bodies collision / overlap at any moment?

How can you check if 2 bodies(with 1 Fixture both) collide(overlaps)? I know about the ContactListener that fires a method when they start colliding and when they stop. But is there a way to check it in any given moment?…
Daahrien
  • 10,190
  • 6
  • 39
  • 71
9
votes
2 answers

how to use the libgdx contactlistener

I've just began to work with the Libgdx's Box2d Engine but i simply do not understand when the methods of the Contactlistener should be called. There is on the one hand "begin contact" and on the other "end contact". Where should i call them, to get…
Xerusial
  • 525
  • 1
  • 5
  • 17
9
votes
3 answers

Prevent body from rotating in Box2D

I am currently using Box2d, more precisely the Java port jBox2d. I have a circle that is colliding with other circles when falling (all those circles form a kind of a crank, see picture below). Naturely, the circle begins to rotate when falling.…
Undo
  • 1,165
  • 2
  • 10
  • 15
8
votes
1 answer

How to create a wrapping world in Box2D

I need to create an endless wrapping world with Box2D (where the X coordinate of all objects is 0 < X < 1000 (say)). I've played some games with teleporting objects back and forth but it's feeling like there might be a better way - any ideas? No…
Charlie Skilbeck
  • 1,081
  • 2
  • 15
  • 38