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
15
votes
3 answers

Breaking a concave polygon into convex ones

I'm using a game physics library (Box2D) which only supports convex polygon shapes. However, I'd like the level builder to be able to just specify concave polygons without having to worry about that. So, how can I automatically break apart a concave…
Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301
14
votes
4 answers

AttributeError: module '_Box2D' has no attribute 'RAND_LIMIT_swigconstant'

I am trying to run a lunar_lander on reinforcement learning, but when I run it, it occurs an error. Plus my computer is osx system. Here is the code of lunar lander: import numpy as np import gym import csv from keras.models import Sequential from…
HungryBird
  • 1,077
  • 1
  • 11
  • 28
14
votes
2 answers

Is there an upper limit on velocity when using box2d?

I'm using box2d for physics simulation. I'm moving a circle using arrow keys by applying impulse on the body when ever a key is pressed. Unfortunately, the circle moves excruciatingly slow and doesn't seem to accelerate like a true physical body is…
ivymike
  • 1,511
  • 2
  • 20
  • 27
14
votes
2 answers

How to detect collision but do not collide in box2d?

How to detect if body collides other body but do not react on this collision. By default i - detect collision and bodies collide. If i set fixtureDef filter - bodies do not collide but i can not detect collision. Help please!
B.S.
  • 21,660
  • 14
  • 87
  • 109
13
votes
1 answer

How to subscribe self on the event of Device Orientation(not interface orientation)?

in my app i want to call some method in CCScene myscene in the case of device rotation(orientation change).I disabled the autorotation(because i want it not to happen). The issue is: i want to change gravity in the scene depending on my device…
Alexander Tkachenko
  • 3,221
  • 1
  • 33
  • 47
13
votes
1 answer

Box2D body velocity cap?

I have a body that has a mass of 10, and each cycle of the program I apply a force of 100 to it using the simple approach; Vector2 force = new Vector2(0, 1) * 100; bod.ApplyForce(force, bod.GetWorldCenter()); It works great, accelerates and all of…
A.R.
  • 15,405
  • 19
  • 77
  • 123
12
votes
5 answers

box2d collision groups

does anyone know whether bodies only collide when (body1.categoryBits & body2.maskBits) && (body1.maskBits & body2.categoryBits) ? or do they already collide when (body1.categoryBits & body2.maskBits) || (body1.maskBits & body2.categoryBits) ?
boscop
12
votes
6 answers

2d trajectory planning of a spaceship with physics

I'm implementing a 2D game with ships in space. In order to do it, I'm using LÖVE, which wraps Box2D with Lua. But I believe that my question can be answered by anyone with a greater understanding of physics than myself - so pseudo code is accepted…
kikito
  • 51,734
  • 32
  • 149
  • 189
11
votes
1 answer

How to stop the forces acting on a body in box2d

I am using box2d on the iphone to create a game. I have a body that is effected by gravity to move down and not right or left. It will get hit by another body and will then be moving right or left. I then have a reset button which moves the body…
user891123
  • 379
  • 2
  • 5
  • 16
11
votes
1 answer

How can I prevent a ball from sticking to walls in Box2D?

I'm experimenting with box2d. I seem to have a problem people describe as sticky walls I have a ball and a paddle I'm using all the basic recommended scales I could find, 10m world, 1m ball The ball has the following properties: shape: circle (.5f…
Rob
  • 7,039
  • 4
  • 44
  • 75
11
votes
1 answer

PolygonShape Native Method not found using new libgdx gradle project

I have a LibGDX project in android studio that uses gradle. It worked well until this morning but due to LibGDX changes now the box2d extension doesn't work properly. I think i've already done the right imports like so: build.gradle (root of the…
LaboDJ
  • 207
  • 1
  • 9
11
votes
1 answer

changing box2d body shapes dynamically

Is it possible to change the shape of a Box2d b2Body dynamically? I want to do this to achieve the following. i). Increasing the radius of a circle shape at a certain rate ii). Changing the dimensions of a bounding box for a sprite to match the…
oopology
  • 1,072
  • 1
  • 10
  • 19
11
votes
1 answer

When to use ShapeRenderer, Mesh + SpriteBatch, Box2D and Scene2D in Libgdx?

I'm new in Android Game Development and after I started with libgdx ShapeRenderer and did a little more search, I became confused if I started with the right foot. So, what I really would like to know is when should I use ShapeRenderer, Mesh +…
Cristiano Santos
  • 2,157
  • 2
  • 35
  • 53
10
votes
4 answers

Libgdx | Scene2d | Set background color of table?

I am creating a menu (like the one is flappy bird, when you die it pops up over the play screen). I created a class that extends table, and I want to set the background of the table to white. Is there a way to do this?
J Doe
  • 385
  • 4
  • 16
10
votes
2 answers

Multiple fixtures on one body or multiple bodies?

Let's say I wanted to create 1000, or maybe even 5000 static body lines on the screen. What I am wondering is, what is the difference between attaching all of these lines (fixtures) onto a single body, or placing each fixture onto its own body. Is…
Gatekeeper
  • 6,708
  • 6
  • 27
  • 37