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

learn more… | top users | synonyms

3
votes
1answer
2k views

AndEngine Moving a Connected Texture and Physics Body

In AndEngine, many times we create a TextureRegion for our sprite. We can move this region around the scene but when I connect that region to a physics body I end up being able to use either one to ...
2
votes
1answer
928 views

How to setup JBox2D

I resently downloaded the JBox2D but how do I set this up?.. Its jbox2d-2.1.2.2 All I can see is a bunch of code and folders. Any websites with step by step tutorial?? You know how??
1
vote
1answer
170 views

How to pin a body in case of collision in Box2D or Farseer?

I'm trying to get an understanding for the Box2D/Farseer physics engine by implementing a small air hockey simulation. There, I have the problem that the CPU player attacks the puck, kicks it, but ...
2
votes
2answers
707 views

Efficient Bullet Firing Class

I've been struggling with this for a while. I have been trying to create a bullet pool class for a game I have made that doesn't cause a significant fps drop. I have tried creating a bullet pool ...
0
votes
2answers
3k views

Box2d and sprites

i have really little practice with box2d, but basically it seems to me that it is possible to attach to every sprite (in a 2d game) a box2d shape (that is, a bounding box enclosing the sprite itself) ...
1
vote
3answers
879 views

Unable to find good parameters for behavior of a puck in Farseer

EDIT: I have tried all kinds of variations now. The last one was to adjust the linear velocity in each step: newVel = oldVel * 0.9f - all of this including your proposals kind of work, however in the ...
1
vote
1answer
1k views

Making an object swing from one rope to another

I am trying to make a Tarzan like game with Cocos2D and Box2D. I am having issues with the physics - making an object swing from one rope to another. I am not really sure how to do this. Could anyone ...
2
votes
1answer
225 views

Box 2d and really complex big shapes

I intended to use jbox2d for my project. But as I went deeper into it's manual I'd found out that it supports dynamic objects between 0.1 and 10 meters (if use scaling and assume that 0.1 is smallest ...
4
votes
3answers
630 views

IndexOutOfRangeException on World.Step after enabling/disabling a Farseer physics body?

Earlier, I posted a question asking how to swap fixtures on the fly in a 2D side-scroller using Farseer Physics Engine. The ultimate goal being that the player's physical body changes when the player ...
3
votes
1answer
758 views

How to simulate backspin or topspin in a box2d billiard game?

I am designing a simple billiard game with box2d. I think I can easily simulate hitting left or right side of a ball. Since box2d is not 3D, however, I am not sure how to simulate hitting upper or ...
4
votes
1answer
3k views

sprite display does not match its body in box2d

I found about this using debug renderer. When game starts, everything is in order. But when some collision happens, sprite's rotation is way larger than its body. When sprite and body match is the ...
6
votes
2answers
3k views

how to ignore physics collision of some objects in box2d

I know this sounds silly but I would like some objects to follow physics while others not to collide each other. I tried to achieve them by setting their position exclusively. But then it will ...
3
votes
1answer
279 views

Why does my ball always bounce perpendicular to walls?

I'm using Box2D. I think it's something to do with wall's fixture definition, but when a ball goes toward a wall at a 45 degree angle, I would expect it to bounce off at 135 degrees, but it always ...
2
votes
1answer
606 views

How to encapsulate game objects (entities) in Box2d

I am currently learning Box2d, a 2D physics engine within libgdx. But Box2d seems to be in every game framework these days so I am not really talking about libgdx. I understand Box2d comes with lots ...
1
vote
2answers
580 views

How can I implement a “boost pad” with Farseer/Box2D physics?

I'm trying to implement a boost pad in my XNA game using the Farseer Physics Engine. (This question applies to Box2D too, I would be happy to port working Box2D code to C#.) By "boost pad", I mean an ...
2
votes
1answer
508 views

Box2D/Farseer - Moving fixtures on a Static Body

I am attempting to create a Pool of Fixtures, in order to reduce memory consumption. My problem is that when I attempt to return a Fixture to the Pool and re-assign its position on the Parent Body, ...
3
votes
4answers
441 views

When connecting a physics engine to another engine, should you do all your logic in the units used by the physics side or the rendering side

I'm currently intergrating pygame and pyBox2D, and am wondering which side is best to try to keep to in terms of game units of size. Box2D is Meters PyGame is Pixels At the moment I am thinking I ...
1
vote
1answer
996 views

Connecting 2D skeletal animation to physics engine

I'd like to use skeletal animations in my 2D game, and since I already use Box2D as the physics engine, I'd like to enable (but not enforce) ragdoll animations as well. I need some help in figuring ...
2
votes
1answer
839 views

How to detect collisions in AS3?

I'm trying to make a simple game, when the ball falls into certain block, you win. Mechanics: The ball falls through several obstacles, in the end there are two blocks, if the ball touches the left ...
4
votes
5answers
5k views

Box2D physics editor for complex bodies [closed]

Is there any editor out there that would allow me to define complex entities, with joins connecting their multiple bodies, instead of regular single body entities? For example, an editor that would ...
11
votes
1answer
2k views

Should I write my own physics engine, because of networking integration?

I'm currently developing a top down, realtime, zombie shooter. I'm coding this in Java, using JBox2D as my physics engine. I have been coding the networking this week, and am now up to the physics ...
8
votes
3answers
2k views

How do you do AI path following within a 2d physics engine like farseer/box2d?

I'm in the process of moving a 2d top down game I've been working on into a proper rigid body physics engine like Farseer. Up until now, I had just hacked together my own physics code where needed. ...
0
votes
2answers
2k views

AS3 > Mouse Event not happening?

Background: Trying to make a ball appear in the same location the mouse is positioned. Using Box2D Library. Working on a class file (.as) Issue: The mouse event does not work (I click but nothing ...
2
votes
1answer
661 views

Moving a big set of box2d bodies in an iOS endless side-scroller game (such as Canabalt)

I am working on an iOS endless-running game (Robot Unicorn, Canabalt, etc). I'm using box2d for the Physics and Collision Checking and cocos2d for graphics. To achieve the notion of an endless level, ...
0
votes
1answer
419 views

How can I respond to mouse events in AS3?

Background: Trying to make a simple "drop the ball" game. The code is located inside the first frame of the timeline. Nothing more is on the stage. Issue: Using QuickBox2D I made a simple If ...
1
vote
1answer
514 views

Handling player/background movements in 2D games

Suppose you have your animated character controlled by the player and a 2D world (like the old 2D side-scrolling games). When the user presses right on the keyboard, the background is moved to the ...
2
votes
2answers
586 views

Physics in carrom like game using cocos2d + Box2D

I am working on carrom like game using cocos2d + Box2D. I set world gravity(0,0), want gravity in z-axis. I set following values for coin and striker body: Coin body (circle with radius - ...
0
votes
1answer
407 views

AS3: StageWidth for BOX2D?

I know BOX2D uses meters, and AS3 uses pixels. I'm trying to create objects which are limited to the stageWidth. If I do this variable: for (var i:int = 0; i<(stage.stageWidth); i++){...} ...
0
votes
1answer
464 views

AS3: limit objects to stage width?

I want to limit the creation of objects acording to the stage width. My method is the following: for (var i:int = 0; i<7; i++){ If I put something like this, it won't work for (var i:int = ...
5
votes
1answer
675 views

How to create multiple balloon bodies in Box2D?

In Box2D, how would I go about making a body that's being lifted by multiple "balloons"? These balloons would have to be able to be destroyed (for example, by a bow and arrow).
0
votes
2answers
527 views

Box2D/Farseer Collision Detection

I am looking for literature - or a simple explanation - on how the Farseer (and for that reason, the Box2D) collision detection system works - specifically the logic that comes after the broadphase ...
1
vote
0answers
580 views

Why are my Box2D bodies disappearing when they collide?

I have a Box2D simulation going on and a system that loads the bodies and its' shapes from a text file definition. I create a new physics world, i load bodies into it, from one of these files. ...
1
vote
1answer
726 views

How to make box2d mouse joint works similar to box2d setposition

I want to make b2mouse joint working similar to b2setposition, though i know in mouse joint force is applied, so it's not possible to reach the desired point without any delay like setPosition(), but ...
5
votes
4answers
1k views

How to port a game from IPad to Iphone [closed]

I just finished developing a 2D side scroll game for the IPad using Cocos2d and Box2d. Now we want to make an IPhone 4 version of the game, but I'm still not sure what is the best way to do it. I ...
3
votes
2answers
1k views

Why does my position interpolation code result in “jumpy” motion?

I am developing an android game with box2d and use a fixed timestep system for advancing the physics. However as I use this system it requires the box2d positions to be interpolates. I read this ...
1
vote
1answer
650 views

Box2d/Farseer how to use the World object?

this question is primarily about farseer but as it is a wrapper around box2d i think it's relevant for both libraries. I'm in the beginning of developing a simple platform game, and I'm stuck as to ...
5
votes
2answers
2k views

Physics or Time-Based Animation In Corona SDK (iOS) Using Box2D

I am part way through creating a Doodle Jump clone for iOS using Corona SDK. I'm currently using the physics engine (box 2D). It's not a straight clone, but I need the basic principles in place to ...
1
vote
0answers
173 views

Which is the best model to present the destruction of the building in Box2D? [closed]

We'd like to create a "world-destruction" game. The problem is in choosing the best model for building destruction. On my mind the building would be an array of objects( tiles). Each object would ...
2
votes
1answer
1k views

2D physics performance on iPhone/Android using Unity 3D?

I've been looking into making 2D games with Unity. One thing which concerns me is the performance of the physics engine. Since Unity is a 3D game engine I'm going to have to assume it uses a 3D ...
0
votes
1answer
210 views

Is it easy to switch from Chipmunk to Box2D?

Currently I'm doing some prototyping with physics in Python and I later plan to port the code over to C++. Box2D has some features that I really like so I'd rather use that library instead. The ...
2
votes
0answers
388 views

box2d reset position of falling object not behaving properly [closed]

I have been playing with box2d in libgdx and have made a falling ball. Once the ball lands on the ground I want to be able to reset it to the top with the space-bar key I have done this: if ...
2
votes
3answers
3k views

Clean way to detect collision of object with box2d

I have been looking into box2d (in java with libgdx) lately and have been trying to create my own custom bounce effect (I increase the Restitution after the first bounce) To do this as a test I ...
0
votes
2answers
1k views

How to use the box2d contact listener in android (java port)?

I don't have any idea about the box2d collision detection in android. I googled and got results that suggest to use the contact listener but I don't know how to use it in android java.
1
vote
1answer
470 views

How do I calculate logical velocity / direction?

I have a simple jBox2D (Java) implementation of a world with couple of Circle bodies that at the begining are static. I want to make them movable when the user touches the circle. But I want them to ...
5
votes
2answers
2k views

Box2D Raycast - Getting position / angle of edge hit

I'm casting a ray in Box2D using b2World.rayCast how can I get the normal of the wall which was hit? Or better yet - the line start and end points? The information returned is: Fixture (fixture hit, ...
6
votes
3answers
6k views

How to remove a box2d body when collision happens?

I’m still new to java and android programming and I am having so much trouble Removing an object when collision happens. I looked around the web and found that I should never handle removing BOX2D ...
1
vote
1answer
542 views

What's the difference with how Box2D and Farseer behave in terms of collisions?

I've ported my engine to iOS and have been using the C++ version of Box2D. Everything runs fine except on collisions, it seems Box2D and Farseer handle collisions somewhat differently. Anyone know ...
1
vote
1answer
2k views

How can I cancel a contact in a b2ContactListener?

To know when contacts happen we can derive from b2ContactListener and implement our own solution which is great. I'm wondering is there anyway we can cancel a contact, that is to say when we hit begin ...
1
vote
1answer
1k views

Bodies are colliding but refusing to rotate in Box2D

I'm running box2d in C++ and hooking it up to C# via p/invoke. All physics stuff occurs in C++. My problem is that bodes know when they are colliding and do so with great precision. However if I have ...
1
vote
1answer
565 views

Dynamic bodies with Parallax Scrolling

I have an object that has a dynamic body. Currently, I'm setting it's position to follow the sprite when the parallax layer move. After a certain event, the object suppose to fall to the ground. ...