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

learn more… | top users | synonyms

1
vote
1answer
916 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 ...
0
votes
0answers
18 views

Drawing particle groups in box2d (java)

Does anyone have any sample Java code for drawing ParticleGroups using JBox2d? I've managed to define a particle group area, but I'm unsure how to draw the individual particles using OpenGL .. ...
0
votes
1answer
57 views

Box2D pixel to meter conversion

I have a game that was written in pixels and now I want to change it to meters like(box2D do). How I need to do that. I have wached a lot of tutorials and all they have some SCALING FACTOR but when I ...
1
vote
1answer
52 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 ...
2
votes
1answer
311 views

How do I make my camera follow a Box2D object?

I'm implementing a camera in my game. It worked for regular objects, but I began using Box2D and obviously things changed a bit. I have a Body object that I want to draw at the center of the screen. ...
1
vote
1answer
226 views

Box2d - Attaching a fired arrow to a moving enemy

I am firing an arrow from the player to moving enemies. When the arrow hits the enemy, I want it to attach exactly where it hit and cause the enemy (a square) to tumble to the ground. Excluding the ...
2
votes
2answers
78 views

box2d rendering performance degrading extremely even with sleeping bodies?

I'm working on my first smartphone game, a simple 2D platformer built with libgdx. Game maps use the Tiled level format, so a map is just a bunch of blocks. I recently started using box2d to implement ...
0
votes
0answers
122 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 ...
6
votes
2answers
314 views

How do I duplicate a Box2d simulation, mid-simulation?

I want to serialize the state mid-game, send it over the network to an identical computer (same CPU, same OS, same binary), load it there, and have the two games run in tandem doing the exact same ...
0
votes
1answer
63 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 ...
2
votes
1answer
69 views

Box2d C++ x velocity slowing for no apparent reason

I'm making a 2d platformer in C++, using Box2d for physics and sfml for rendering, I want the player character to move with a constant velocity in the x direction, and to jump when the spacebar is ...
1
vote
1answer
196 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
130 views

Physics don't apply on a unique body AndEngine [on hold]

I am developing a game in AndEngine. So far I managed to create everything I wanted for my sprite that was connected to a BoxBody. I was rotating it, moving it, everything was great. I wanted my ...
0
votes
1answer
29 views

box2d ChainShape into curved line

i need to draw a curved line , i searched the internet and found nothing , maybe someone with knowlegde on the subject can help me with a link , i used chain shape and did this , and i don't know ...
1
vote
2answers
46 views

How can I attach a libGDX actor to a box2D body?

I'm creating game like hill climb racing. I created my car with the help of shapes and joints but I don't know how to attach graphics to it. I used actors and sprites before for the sake of learning, ...
2
votes
1answer
62 views

Why do my Box2D collisions fail when I have multiple fixtures on one body?

I'm creating my first libgdx / Box2D game where a player moves around using a mouseJoint. My player has two fixtures, "main" and "question". For some reason when I have these two fixtures, my player ...
3
votes
1answer
746 views

AndEngine; Box2D - high speed body overlapping, prismatic joints

I'm trying to make good suspension for my car game, but I'm getting nervous of some problems with it. At the beginning, I've tried to make it out of one prismatic joint/revolute joint per one wheel ...
1
vote
2answers
919 views

LibGdx sprite rotation vs Box2D physics rotation problem

LibGdx sprite rotation vs Box2D physics rotation problem Tearing my hair out on this one. I am an experienced software developer, but very new to LibGdx and Box2D development. I am writing a game ...
0
votes
0answers
17 views

How do I get the impulse of a collision from Box2D in LibGDX?

I am developing a game using LibGDX and Box2D. I want to get the force or the impulse when two bodies collide, but I can't find the right way to do that. How can I use a ContactListener to get the ...
0
votes
1answer
62 views

Make camera move constantly upwards in box2d world

Im using libGdx to develop a 2d game, which has the following: The world moves in an upward direction by having a camera follow the player's y position. The user only controls player's x movement, ...
0
votes
1answer
94 views

Creating a Player object in a physics engine [duplicate]

I have a working physics environment using Farseer - but how do I create a player object that can walk around? My current attempt involves applying forces to a rectangular body whenever keys are ...
-2
votes
1answer
53 views

Throwing a bomb LibGDX Box2D [closed]

I am trying to create game where somenone throw a bomb. I am wondering how I can have an bomb react in a way that is represented by the following picture : Is there are any tools in Box2D that can ...
3
votes
1answer
224 views

How do I handle rope physics with fixed ends and a sliding weight?

I've been interested in rope physics recently—I've successfully implemented a simple Verlet rope with moveable ends. Now I am trying something a little different: I want to start by recreating the ...
0
votes
0answers
32 views

Seeking Advice: Collision with JBox2d for Top-Down or Isometric Maps

I Hope I can make this as clear as possible! Currently working on an action RPG game, very early stages, more just the basic ideas down and written in. So i'll start on with my setup: Using Java ...
0
votes
1answer
80 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
206 views

Change the shape of body dynamically

I have a problem where i have a ballon which i need to continuously inflate and defalte in update method, I have tried to used setScaleCenter but it is not giving desired result. Below is a code i am ...
0
votes
1answer
112 views

How to render a vertex buffer in DirectX11 C++ (specifically with box2d's b2Draw)

I have all the DirectX11 devices etc setup and working with DirectXTK's SpriteBatch and currently attempting to implement a b2Draw class to draw my box2d physics worlds. I have little idea on how to ...
0
votes
1answer
63 views

Equalling the rotation of an image with its object. Box2dweb

I have some hard time making the rotation of an image equal to the rotation object that the image belongs to. Simply put it, I don't know how to do it properly but i am not asking for a how-to guide ...
0
votes
1answer
51 views

Box2D meters and pixels

I am confused about pixels and meters in Box2D. I know that Box2D work only in mters so I need SCALING FACTOR. How big I need it? For example I want that from my mouse coordinates position X and Y for ...
1
vote
1answer
51 views

box2D and libgdx: Attach ParticleEffect to Body

Hello I am a newbie with libgdx, my question is: how could I add a Particleeffect to a Body that is moving? I searched about the matter and I didnt find anything related to it. I have the following ...
2
votes
1answer
87 views

Box2D—how make character tilt

I have got a floating character, which should be a robot like thing, floating over the ground, whereby I am using the »hovercar« effect described here. Zhe Image below outlines the basic setup of the ...
1
vote
1answer
31 views

Reduce bounciness of dynamic bodies in Box2D

In my 2D platformer game my player character is modeled using a Box2D dynamic body. One thing I thought feels off though is that even though the restitution of the fixture applied is zero, the player ...
0
votes
0answers
22 views

Box2D Bomb Explosion

I'm using CircleShape to create my bomb, but now, after throwing it I want it to explode after 4 seconds. public void setUp(){ BodyDef body = new BodyDef(); ...
0
votes
0answers
19 views

Using box2d with starling

In my game I have a Main class in which i am initializing starling framework by passing Game class like below myStraling = new Starling(Game , stage); In the game class I have Instances of Welcome ...
0
votes
1answer
55 views

How can I create a character design that maintains a fixed rotation body, while allowing the body's “arm” to rotate 180 degrees?

I am attempting to create a 2d shooter in Farseer Physics on the Xbox360. I have a player body which has a fixed rotation, as I do not want the body to rotate at all during gameplay. I am now looking ...
0
votes
0answers
13 views

Box2D thow ball from PIXELS posisiton

Here are my enemy movement function. I want that my enemy in random Y-position throw a bunch of things in to the player. And I want to implement physics using Box2D. But I know that Box2D workd only ...
0
votes
1answer
551 views

Communication between Box2D and libGDX Stage (Scene2D) running in separate threads

I'm making a physics based 2D game using libGDX and Box2D. I want to move the execution of the simulation out of render thread. I use immutable messages and the BlockingQueue to pass the information ...
0
votes
0answers
14 views

Box2d - body size or spatial distribution matters for better simulation?

Box2D better works for limited sizes: Box2D works with floating point numbers and tolerances have to be used to make Box2D perform well. These tolerances have been tuned to work well with ...
0
votes
1answer
94 views

Explain the difference between extrapolation and interpolation

http://www.unagames.com/blog/daniele/2010/06/fixed-time-step-implementation-box2d here there are two algorithms of smoothing in case of fixed time step physics simulation. I don't understand the ...
1
vote
0answers
73 views

Should I use Box2D for collision-detection only (not simulating physics)? [closed]

I'm using Box2D only to check collisions and for no physical simulation. I create bodies (and shapes for them) and use my own code to move them, by setting their velocities and positions every frame. ...
0
votes
1answer
18 views

Box2d polygon skin

In manual is see: Polygons inherit a radius from b2Shape. The radius creates a skin around the polygon. The skin is used in stacking scenarios to keep polygons slightly separated. This allows ...
1
vote
2answers
135 views

How to create Whirlpool/Vortex effect?

Im trying to make a Vortex effect on a Circle Body that is a Sensor. I've been looking for this and all examples i look for are in C++ or Objective C and i dont seem to translate them well. when my ...
0
votes
0answers
23 views

Change a vertices and display corner of a polygon

I'm currently building a level editor for my game and i'm having some trouble on how to change vertices of a polygon. Basicly i searched the web trying to figure out how to update the vertices of a ...
0
votes
1answer
14 views

Box2dWeb: must fixtures be destroyed explicitly when destroying the body?

I use b2WorldObj.DestroyBody(bodyObj) to destroy the body when it is not needed anymore. The body has one fixture attached to it. Do I need to destroy the fixture before destroying the body? or ...
1
vote
1answer
43 views

web based networked game physics efficiency

I am writing a web based game, using websockets. its pretty simple, two players shooting at each other with bullets that have acceleration from a starting point at an angle. The client side ...
0
votes
1answer
31 views

How to make an object in box2d have constant velocity even after collision? [duplicate]

I have iOS game where I have a bouncing character. Everything is being handled by box2d. The problem is when the character hits a wall of another character it's velocity changes, but I don't want ...
0
votes
0answers
38 views

Move body LibGDX Box2D

Hello I have a body and I want to move it. When I press the mouse button my body should move at that position (on the const speed)on the screen. I have override two methods(x1, y1 - point where my ...
0
votes
1answer
36 views

Box2D pixels to meters , LibGDX

I am confused . what shall I set the orthographic camera viewport in libGDX when I use box2d , in one tutorial I saw that he divided his viewport numbers to 32 because 1meter =32 pixel , but I think ...
1
vote
0answers
46 views

Mouse click coordinates not mapping to Box2d world

I'm using Box2d in Java with OpenGL, trying to detect if a mouse has clicked on a Body. But having trouble mapping mouse coordinates to Box2d world. I have a Body positioned at 20.0f, 30.0f in the ...
0
votes
1answer
55 views

Box2D Body creation causing performance issues

I have at max 10 dynamic bodies in my world at any time. they are created at random and fired up from below they screen. when a new body is being created, the fps falls from 59 - 61 to about 35- 40 ...