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
7
votes
2 answers

How to create a level with curved lines with cocos2d + Box2d on the iphone?

I'd like to create a game that has levels such as this: http://img169.imageshack.us/img169/7294/picdq.png The Player moves "flies" through the level and mustn't collide with the walls. How can I create such levels? I found that piece of software:…
KayO
  • 189
  • 2
  • 13
7
votes
1 answer

JBox2D - Find collision coordinates

I'm writing a program in Java using JBox2D. I need to find the exact point of collision between two textures, if and when they collide. I have the code to determine if a collision happens, and can obviously just call the collision object ID to…
bigcodeszzer
  • 916
  • 1
  • 8
  • 27
7
votes
2 answers

Libgdx light without box2d

I just started creating a game using libgdx. It is a top down 2d shooter using scene2d ui. Now i thought, that i could add darkness and light to some levels, but i don't want to rewrite everything using box2d. I don't need realistic shadows just…
Robert P
  • 9,398
  • 10
  • 58
  • 100
7
votes
1 answer

Collision in Libgdx box2D failing for some bodies

I'm working on my first game using libgdx with box2d. I'm using the debug renderer to test my objects. I created some car like objects. Each car has a main body, which is a large polygon of 6 points (about 1 meter long, 0.7 meters high), and has 2…
Charbel
  • 658
  • 5
  • 13
7
votes
3 answers

Libgdx Box2D setting up an image to a body

i have a problem with setting up an image to a dynamic/static body. i found a flash code about it public void setImage() { sprite = new B2Sprite(); var bitmap:Bitmap = new Image(); sprite.addChild(); bitmap.x -= bitmap.width / 2; …
Methnani Bilel
  • 1,366
  • 4
  • 20
  • 34
7
votes
1 answer

box2d what's the point of world.ClearForces()?

I'm using box2dweb version 2.1.a.3 (javascript, ported from flash), to create game. Some examples that I've got from Google used: setInterval( function(){ world.Step(1/60 , 10, 10) world.ClearForces() } ,1000/60) I…
vantrung -cuncon
  • 10,207
  • 5
  • 47
  • 62
7
votes
1 answer

C++ Box2D - Dynamic bodies not affected by gravity if left alone

I was playing around with Box2D in SFML2 and realized; when I change the gravity of the world, the dynamic bodies that have been untouched for a little while aren't affected by the gravity change. I prepared a video to make this explanation more…
user569322
6
votes
1 answer

Android GDX Box2D Triangle Shape

I need a triangle shape definition for Box2D GDX Android. Would I just divide the width by 3 or is there a class for it? Here is code for normal rectangle: _rect1 = CCSprite.sprite("RectWood.png"); …
Jo Silter
  • 93
  • 6
6
votes
3 answers

Slowing down objects in box2d with no gravity

I am making a billiards game, so my gravity is set to zero and I apply impulse to make a cue ball move. Because there is no gravity, I use both, linear and angular damping to slow the balls down. While the balls have some decent velocity, they slow…
Alex
  • 129
  • 1
  • 1
  • 8
6
votes
1 answer

Fast moving bodies miss the collision sometimes in Box2d, AndEngine

I have a Fast Moving Body(A) which is dynamic. It is supposed to collide with another Body(B). A collides with B, but sometimes it passes the Body B without collision. This is totally random behavior. I must have that collision. Kindly guide why it…
Khawar
  • 5,197
  • 4
  • 28
  • 52
6
votes
2 answers

For collision detection only, is Chipmunk or Box2d the better tool?

For a Cocos2d based project, I'd like to use a physics toolkit for collision detection only. What are the pros/cons of using Chipmunk or Box2d?
Daniel Blezek
  • 4,539
  • 1
  • 19
  • 20
6
votes
4 answers

HTML 5 game development tools

Can anybody please guide me with the best engine for game development in HTML5? It is simple jumping and surface detection game. The theme is like jumping and go above the tree tops. What you suggest in this case? I am targeting Android and iOS…
Asad Nauman
  • 971
  • 11
  • 19
6
votes
1 answer

Removing an object 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 bodies during collision detection (a contact…
Ayham
  • 190
  • 1
  • 10
6
votes
1 answer

How to animate an explosion that blows the surrounding bodies away?

I am trying to put a bomb in some place and when it explodes every thing around it will fly away and the speed depends on how close the object to the bomb. something like when the black bird explodes in angry birds. can any one give me a sample code…
Ayham
  • 190
  • 1
  • 10
6
votes
1 answer

How to move objects from node to node? Libgdx Box2d A*Pathfinding

I can't succeed in making the enemies move from node to node. I managed to set up the whole pathfinding, I'm getting a full path to the player and the position of the next node all the way to the end. How do I move the box2d body from node to…
Deso2121
  • 99
  • 8