Questions tagged [jbox2d]

JBox2D is a Java physics engine often used in games an other physics simulations and is a port/extension of the C++ physics engine, Box2D.

JBox2D is a physics engine for Java often used in games and other physics simulations, and is a port/extension of the C++ physics engine, Box2D.

Questions

Questions with the jbox2d tag should be specifically about JBox2D and its implementation. Questions about the physics engine in general should be tagged with box2d as well.

Brief Definitions

  • World contains the physics environment for a simulation
  • Body is a physics entity with any number of child fixtures. These fixtures are treated as all part of the same physics object, and will interact accordingly (they won't break up). Bodies also provide support for user-applied forces and torque.
  • Fixture contains a single shape and information about it (for example, friction and restitution).
  • Shape contains information about the basic physical properties of the physics object. (for example, the vertices of the polygon shape)
  • Joint is basically a way of adding constraints to different bodies. There are a variety of joints, including revolute, distance, and prismatic joints.

Links

JBox2D

Box2D

183 questions
2
votes
3 answers

How to properly apply torque or angular impulse to body in PlayN?

I've been trying to apply an angular impulse to a Body object in PlayN, but to no avail. Whichever value (radials) I enter, the angle of the body never changes. I have tried to set the torque as well with no results. Example code that doesn't…
levivanzele
  • 726
  • 1
  • 13
  • 33
2
votes
2 answers

setLinearVelocity() not working as expected

I've been messing around with jbox2d and was suprised when the x-velocity of a body was affected by the gravity of the world. Here's my code: //create world Vec2 gravity = new Vec2(0, 1); boolean sleep = true; world = new…
Matt
  • 21
  • 3
2
votes
1 answer

Strange error when creating physics body in Andengine

I`m trying to create a polygonal physics body by such code: final float halfWidth = pAreaShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT; final float halfHeight = pAreaShape.getHeightScaled() * 0.5f /…
Ashot
  • 640
  • 1
  • 6
  • 14
1
vote
1 answer

JBox2D Hangs On world.step()

A serious bug has popped up and I don't have a clue why. Not long after I start my game, the game freezes. All I know is that the program execution goes into world.step(1.0f/30.0f, 5, 2); and never exits, thus freezing the game (By never, I mean no…
Jesse Jashinsky
  • 10,313
  • 6
  • 38
  • 63
1
vote
3 answers

How Can I Detect Collisions When Objects Aren't Moving?

I suppose to understand the question, I have to explain the game. Balls are falling down the screen, and when you click on the ball it changes into a different ball based on its type. For example, clicking on one ball will freeze surrounding balls…
Jesse Jashinsky
  • 10,313
  • 6
  • 38
  • 63
1
vote
1 answer

JBox2D Body Was There, Now it's null?

A strange bug I can't track down. I've implemented a ContactListener class for handling collisions in my Android game. In the beginContact(Contact arg0) method I can see that the two bodies in arg0 is there, and pushed onto a stack. Right after…
Jesse Jashinsky
  • 10,313
  • 6
  • 38
  • 63
1
vote
0 answers

Need Box2D benchmarks

I've ported jbox2d to c# and I want to check if my results are identical. Does anybody know if there are some benchmarks which I can use as ideal results or running tests. When I say benchmark I mean some strict description of box2d world (for…
gerichhome
  • 1,872
  • 2
  • 15
  • 21
1
vote
0 answers

How to draw jbox-2d in slick2d

I am trying to implement the Box2D "Hello, world" (falling box program in the manual), but can't figure out how to draw the shapes in the right spot. I believe the draw- or fillRect functions of slick2D take two corners, but I'm not sure how the…
TheTedinator
  • 745
  • 1
  • 8
  • 16
1
vote
1 answer

making dynamic bodies fall JBox2D

I'm having some problems with JBox2D. I've created a ball and world and everything as far as I can tell correctly, but when I call the world.step() method it dosen't make the ball fall from gravity. Here is my object creation: package…
1
vote
0 answers

How do I detect collisions between individual particles in LiquidFunProcessing?

I'm using processing's liquidfun library to simulate particle interactions, such as changing color on collision, but I can't find a contactlistener for individual liquid particles. There's a built in contactlistener for JBox2D objects, but it…
Blue Tube
  • 11
  • 1
1
vote
1 answer

Best method for changing collision polygons in Box2d?

I'm wondering what I should do for my player character. Currently he has the idle stance, with all the collision polygons created etc. But I want him to move his arm polygon when he is punching. How would I do this? I have all the polygons…
liamzebedee
  • 14,010
  • 21
  • 72
  • 118
1
vote
1 answer

Not able to use Contact class for collision in jBox2D using Processing

I am working on this project using jBox2D along with Processing(P3). While working on the collision handling, i am unable to use the "Contact" class, for getting the contact object and obtaining the fixtures. The following is the basic structure of…
Ontropy
  • 130
  • 1
  • 12
1
vote
0 answers

JBox2D collision filtering (categoryBits, maskBits)

I've read the Box2D manual and I understand how masking works in general. But the results I'm getting are not following what is laid out in the manual. I have 3 categories of things: players, obstacles and triggers. players and obstacles collide…
Jim
  • 661
  • 11
  • 30
1
vote
0 answers

Scrolling background in Processing with Fisica/Box2D

I'm trying to make a scrolling world with Fisica (port of JBox2D) and Processing 3. This code almost works, it scrolls correctly etc., but when I make this.player jump with this.player.addImpulse(0, -150), it works when the world is not scrolling…
Jachdich
  • 782
  • 8
  • 23
1
vote
0 answers

Simultaneous collisions not detected

I'm using JBox2D with LibGDX and would like to detect simultaneous collisions with a sensor. The problem I'm having is that one collision can be detected, but if any other collisions occur at the same time they don't get passed through. E.g.…
Michael
  • 3,411
  • 4
  • 25
  • 56