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

learn more… | top users | synonyms

1
vote
0answers
45 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
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 ...
1
vote
0answers
44 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 ...
1
vote
0answers
40 views

How to tell if a fixture is being squeezed by two other fixtures in Box2D?

Let's say I had a ground fixture, a player box, and a kinematic block moving up and down. If the player stands under the block, weird things happen. I want to simply play an event where the player ...
1
vote
0answers
51 views

Box2D random crash when adding joints

I'm currently working on a project which uses Box2D, when the player uses a certain key it should anchor to the ground. For that I use a weld joint, but when I add the joint the game will sometimes ...
1
vote
0answers
74 views

unity4.3 rigidbody2d unexpected force behaviour

So guys ive edited the question and here is what my problem is i have a player which has a rigidbody2d attached to it.my player is able to doublejump in the air nicely and stick to walls when ...
1
vote
0answers
305 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: ...
1
vote
0answers
62 views

Box2D setGravity() in Andengine?

Im currently using the Andengine GLES20 branch. I know that the new Box2D method setGravity() isn't implemented yet. Has anyone managed yet to get it to work with Andengine or to write a method ...
1
vote
0answers
63 views

Need to join 2 bodies via weld joint but not on center of mass

I have successfully join 2 bodies via weld joint , but my problem is I want to join corners of bodies not on centre of mass. Is there any way to achieve this? Above image consist 3 polygon body that ...
1
vote
0answers
160 views

Box2D Qt wrong collisions

I am working on a simple Box2D game (with Qt), but my objects don't collide correctly: As you can see on the picture, objects try to go through each other and slide over. My b2World: b2Vec2 ...
1
vote
0answers
240 views

Image Texture Tracing Algorithm - Cocos2D Box2D

Context: I am working on a 2D Destructible Terrain engine for Cocos2D with Box2D. All images, when a level loads, have their border's traced and cached for the purposes of forming Box2D b2EdgeShape ...
1
vote
0answers
223 views

beginContact triggered more than once on some objects

Short version: It looks like beginContact is detecting continuous collisions. I'd like to avoid that. Long version : I use Box2Dweb to write a 2D platformer. It's my first game using this lib, and, ...
1
vote
0answers
1k views

Why do restitution values less than one still cause infinite bouncing in Box2D?

I'm currently trying to implement basketball bouncing into my game using Box2d (jBox2d technically), but I'm a bit confused about restitution. While trying to create the ball in the testbed first, ...
1
vote
0answers
342 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
0answers
555 views

changing body type without change of center of mass

I have an box2d project with some bodies in it, which move around without any user interaction. But if the user selects one of the bodies, he should be able to move it around just like he wants to. ...
1
vote
0answers
852 views

How to properly add texture to multi-fixture/shape b2Body

Hello to everyone this is my first poste here I hope that will be not fail start. At start I must say I make part 1 in Ray's Tutorial "How To Make A Game Like Fruit Ninja With Box2D and Cocos2D". But ...
0
votes
0answers
30 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
0answers
16 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
0answers
21 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
0answers
12 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
0answers
13 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
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
0answers
29 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
0answers
93 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
0answers
50 views

libGDX fixed object and camera do movement

I develop game to andorid and there is moving object with arrows - simple movement like in RPG games. I did: camera.position.x = PIXELS_PER_METER*man.body.getPosition().x; camera.position.y = ...
0
votes
0answers
35 views

Box2D - create object with different physic parts

I have object with physic: BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyDef.BodyType.DynamicBody; bodyDef.position.set(position); bodyDef.angle = angle; ...
0
votes
0answers
18 views

Destroying fixtures in Box2D/AndEngine

In my game I need to break of parts of a body when the body crashes into something too violently. Currently I do that by by getting all the normal impulses of the ContactImpulse and if the max value ...
0
votes
0answers
28 views

Intersection issue with box2d in iOS

I'm trying to use the code here http://www.iforce2d.net/b2dtut/raycasting So I can know whether a line cross a box2d object or not. It half works, in that when the line crosses the object it does ...
0
votes
0answers
99 views

How can I make a swinging rope?

Base question: How can I make a swinging rope in box2d? Context: The idea is to have a rope where the player can grab it, swing a little bit to get more "momentum" and reach the next platform. Like ...
0
votes
0answers
60 views

Client-server architecture with box2d

I am running a client-server architecture with an authoritative server running box2d and the client running box2d as well. If gravity is set to 0, is there any point to linear interpolation and ...
0
votes
0answers
25 views

Speed seems random with constant impulse

I'm shooting an object from the top vertex of a triangle using Box2dWeb. The issue I'm having is that the projectile speed seems to be fairly random, even with applyimpulse set to a constant. The ...
0
votes
0answers
31 views

Box2D.js b2ChainShape

I'm using box2d.js (asm.js ported) and need to create a b2ChainShape. var bodyDef = new Box2D.b2BodyDef(); var fixDef = new Box2D.b2FixtureDef(); bodyDef.set_type(Box2D.b2_staticBody); var chain = ...
0
votes
0answers
135 views

Libgdx/Box2D PolygonShape has no position… well, what now?

As my prototype works perfectly fine I want to advance to more fun areas of the project and add a more complex player-character body. So for Box2D I figured I'd need multiple fixtures, like one for ...
0
votes
0answers
64 views

Drawing a object with Box2D and HTML5 canvas on current mouse position

I'm attempting to create a air hockey type game with HTML5 canvas and JavaScript, using Box2dWeb for the physics calculation. I need a way to draw the puck at the current mouse x and y position every ...
0
votes
0answers
48 views

[LibGdx]Moving a fixture on a body

I'm working with Box2D and I have a basic platform and a box bounces off of it. // Static Platform bdef.position.set(160 / PPM, 120 / PPM); bdef.type = BodyType.StaticBody; Body b = ...
0
votes
0answers
93 views

Box2D collision damage calculation from postSolve or not?

I'm using postSolve to get impulse then calculate damage base on that impulse. But there's some issue: Stability The damage isn't stable. When the same ball is hitting with same speed, the damage ...
0
votes
0answers
126 views

sprite reset method not working in update thread(andengine)

I have sprite array with length of 8 and I am trying to reset sprites position in scene's update thread but it doesn't work. However I tried to reset sprites in sprites modifier listner which works. I ...
0
votes
0answers
12 views

Complex Body with multiple BodyDefs

My complex body is made up of several parts some of which are static and some are dynamic and have specific positions relative to each other. Because the static/dynamic property and position goes in ...
0
votes
0answers
85 views

box2dlights conelight rotation is off

I'm using libgdx/box2dlights for my game~ I have a conelight set up as such: ConeLight cl = new ConeLight(rh, 32, new Color(0f, 0.0f, 0.0f, 1.0f), 3, 0, 0, 0, 1); where "rh" is a RayHandler set to ...
0
votes
0answers
62 views

Box2D and randomly generated tilemaps

I am making a 2D Terraria-style sidescrolling game. I want to use box2d for the physics. However, I am using tilemaps for the maps, and I do not know of a processor-efficient way to use Box2D bodies ...
0
votes
0answers
39 views

Box2d not showing consistent behaviour with sprites

Box2D newbb here. My question is in regards to this create js project:http://mboyeman.com/dashingdog/ (runs best in IE...:3) I wrote a function(assignBlockBodies) to give 2D Edges to sprites based on ...
0
votes
0answers
129 views

Shifting the camera and setting a new scene when using Box2D

My jsFiddle: // START -- MOVE CAMERA var p = new b2Vec2(); p = (ball.body.GetWorldCenter().x) * physics.scale; pos.push(p); var length = pos.length; var s = (pos[length - 1] - pos[length - 2]); //in ...
0
votes
0answers
46 views

2D Range Searching

I have a 2D jump'n'run browser game based on SVG, whereby the entire game-world is included in one huge svg (28px * 16000px, ~3.5MB). Unfortunately is rendering kind of too complex and the browsers ...
0
votes
0answers
57 views

setChaseEntity freezes or jitters the AnimatedSprite

I'm trying to implement setChaseEntity method in a physics based app. I wrote the below code which has an animated sprite ans as the player. The player is movable and it can jump. When i try to focus ...
0
votes
0answers
45 views

GWT problem with Box2D WheelJoint

I am using the below libgdx java code for a wheel joint and rear axle using Box2D. This works fine for android, Desktop, but when I attempt to run through GWT I get the following error. at ...
0
votes
0answers
10 views

box2dweb issue in DestroyJoint function

my jsfiddle : http://jsfiddle.net/H8e9m/9/ as you can see when the ball reach the pendulum end and collide with it by a revolute joint, the problem occurred when trying to make the ball release the ...
0
votes
0answers
42 views

Box2D—Dropshadow

I am about to create a Jump'n'run game using Box2D for the physics. I am asked to add a Dropshadow to the main Character, but as I noticed this could become quite complicated. Basically the Light ...
0
votes
0answers
136 views

Trying to make a mouseJoint with Box2D on Cocos2D-X

I'm trying to obtain this result: http://appcodingeasy.com/Gideros-Mobile/Dragging-Box2d-object-in-Gideros-Mobile (there's a video - YouTube). But I'm missing something, because if I follow the code ...
0
votes
0answers
136 views

How to find correct offset to adjust sprite to the position of box2D body after rotation

I am trying to implement phsyics with the as3 box2d port. I currently have a b2body for each of some certain sprites in my game and I am able to update the sprite's positions correctly from the ...