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.

Filter by
Sorted by
Tagged with
0
votes
0answers
11 views

Assertion error when using .setFixedRotation

I'm new to Java and coding. I'm trying to create a tower building game using Box2d for Processing. The premise is to build up a tower that has to resist a shot from a cannon. The tougher the tower, ...
1
vote
0answers
30 views

Uniform lighting when there are multiple light sources

I'm writing a 2d game where there are walls and the NPCs can only see what is within their line of site. To do this I'm using Box2dLights so the walls create shadows. The problem I'm having is ...
3
votes
1answer
148 views

How to detect a body between two points on LibGDX

I've two Vector2 (A and B), i draw a line between them. Is there a way to check if the line intersect the Box2D CircleShape? I need to a boolean output
2
votes
2answers
516 views

How do I force a game object to move along projectile trajectory, like in Angry Birds?

I am a new Android game developer. I want to force my game object to move in a projectile trajectory, like in Angry Birds.Related example here and my example You can see an example in the image. I ...
0
votes
2answers
977 views

How can I easily render Box2D polygons with ShapeRenderer in LibGDX?

In the PolygonShape object, there is the method setAsBox() which allows for creating rectangles easily, but there is no ...
0
votes
1answer
216 views

How to jump exactly X meters in Box2D World?

I want my character to always jump a constant height, let's say 3 meters. Also character has double jump ability so he can jump max 6 meters. For example, let's say I have pressed jump key while ...
0
votes
1answer
70 views

Have body resume constant velocity after collision

I want to have a body move at a constant velocity, but react to collisions. My example game is a train, I want it to move at 1 meter a second. If an obstacle appears on the tracks, I want it to react ...
1
vote
0answers
33 views

Getting a TOISolver ArrayIndexOutOfBoundsException creating a tile based game

I've been making a tile-based game on java using jBox2D.For adding tiles to physical world I use static bodies which are stored in updating ArrayList(i use PhysicBlock class as a wrapper). Whenever I ...
1
vote
1answer
100 views

States within a GameState?

I ended up coming up with having states within game states. For example: States splash menu tracks garage loading play What bothers me is that I now have states within the play state to handle it ...
0
votes
1answer
64 views

Box2d java contact point reference changes after collision

I am trying to hold the contacts made during a collision in an array list. After I add n amount of contacts, when I try to retrieve them later on, they point to the last contact made in the world. ...
1
vote
1answer
77 views

Why is my Box2D Body only colliding with one type of Object after a new level has been built?

So developing for an android mobile game, using Android Studio and developing for the API 17, with Box2D implemented. FIRST LEVEL For some reason, one the first level everything is running okay: ...
-1
votes
1answer
132 views

Collision problem JBox2D

I work with Processing and the JBox2D library and wanna code a new Ping Pong game. But if I move the player to the top border (or lower border), he collide on a wrong position. The picture shows ...
2
votes
2answers
3k views

LibGdx - Move sprite in the direction of other sprite

I'm kind new to LibGdx and I'm still learning. I'm working on a small game project to learn this nice framework. However, I'm having some issues with my game. My game is a top down shooter. There is a ...
2
votes
1answer
86 views

How to restrict jumping to a single jump?

I'm making a VolleyBall game in HTML5 with PandaJs GameEngine and plugin is used physics and Box2D. The problem is that players can jump, but they can jump over the net with multiple jumps. I have ...
0
votes
1answer
280 views

Relative movement in Box2D (keep object from falling off planet)

I'm creating a game with planets orbiting around a sun, like this: The brown square is the earth, rotating around its center and around the sun. The yellow square is the sun, which doesn't move. Now ...
1
vote
1answer
121 views

Permeable objects in Box2d

In Box2d, can I make a static object to be permeable by dynamic objects? Can I simulate something like water in a way that it lets rigid bodies to dive into it but at the same time pushes them off ...
0
votes
1answer
908 views

Set world boundaries in box2d

So far I've seen the only way to set boundaries on box2d world which is to create rectangular shapes and place them at the edges of the screen, is there any other ...
3
votes
1answer
681 views

Rotating towards a point in Box2D

I'm using Box2d as my physics engine and I'm trying to solve what would normally be a simple problem but what has become a nightmare for me and preventing me from finishing my app. (6 months work) I'...
2
votes
1answer
2k views

LibGDX camera position shifted on movement

I'm programming a game with LibGDX and Box2D and I want my camera to follow my player. But as I zoom in (because Box2Ds metric system, using camera.zoom = x) the camera is shifted when the player ...
1
vote
1answer
446 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 ...
1
vote
0answers
168 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 ...
3
votes
3answers
868 views

Why do my Box2D bodies occasionally get stuck and separate forcibly?

I'm making a space game with LibGDX and Box2D. I made a video here to illustrate the issue. Verbal description: When objects collide, they sometimes get stuck together and are then suddenly separated ...
1
vote
1answer
689 views

“Running” against a steep slope on a Box2D Platformer

Ive seen alot of pages talking about how to emulate a platformer on Box2D, specially about how people dont want to slide down a slope. Well, my problem is different and Im surprised I cant find posts/...
1
vote
1answer
65 views

In JBox2D, where is the correct place to interact with Body objects? step() method?

QUESTION: In an application, where is the appropriate place to put the code to interact with the Body objects? By 'interact' I mean Get position Determine actions Apply impulse Would it be ...
3
votes
2answers
140 views

In JBox2d when dragging a Body, why is the direction is flipped vertically?

Why is it when I drag a JBox2d Body with the mouse, the vertical component is flipped? e.g. If I drag down-right, the Body moves up-right. Is this expected behaviour, a bug in JBox2D, a Mac ...
0
votes
1answer
106 views

JBox2D bodies don't collide?

I have two objects. A dynamic player and a static ground object. It was working for a while until I did some refactoring and suddenly my play falls right through my ground object. Is there anything ...
0
votes
0answers
23 views

How can I avoid duplication of jBox2D physics attributes?

I'm using jBox2D for physics and collision detection in a game engine with an entity-component system. It works, but I'm unsure how to structure my code with respect to the values represented in the ...
0
votes
1answer
221 views

How do I create a Fixture in Andengine and assign it user data?

I´m following this tutorial: How do I use a JBox2D ContactListener to check if my character is standing on the ground? in order to get input from player's bottom part including a fixture in player's ...
0
votes
2answers
800 views

Box2d world width and height ratio with screen width and height

I have view, for example GameView which extends SurfaceView . I have integrated Box2D physics in GameView. I have two widths , GameView width, height and Box2D physics world width ,height. I need to ...
0
votes
1answer
62 views

How do I get the position of a static body in Jbox2D?

I'm trying to get the position of a static body in JBox2D, how do I do that?
2
votes
1answer
921 views

libgdx default saving mechanism for box2d world

I want to save my game in libgdx, and I have no problem using Kryo to save everything, except the box2d Worlds and the RayHandlers from box2dlights - these are not Serializable and do not have default ...
0
votes
1answer
58 views

Using texture() in combination with JBox2D

I'm getting some trouble using the texture() method inside beginShape()/endShape() clause. In the ...
1
vote
1answer
112 views

Box2D relations

As far as I know, the unit in Box2D is meters. When I use Box2D in Processing with JBox2D, I set the "world size" as the window size specified in the setup(). Now I'm wondering if there is any ...
2
votes
1answer
323 views

JBox2D Polygon Collisions Acting Strange

I have been playing around with JBox2D and Slick2D and made a little demo with a ground object, a box object, and two different polygons. The problem I am facing is that the collision-detection for ...
6
votes
1answer
1k views

2D Polygon Triangulation

I am creating a game engine using the JBox2D physics engine. It only allows you to create polygon fixtures up to 8 vertices, To create a body with more than 8 vertices, you need to create multiple ...
1
vote
1answer
204 views

Which .jar has JBox2d's p5 package?

Using Eclipse, I'm trying to write a simple hello world program in processing that simply draws a rectangle on the screen then has gravity drop it as seen in this tutorial. The problem is that when ...
2
votes
1answer
1k views

How do I use a JBox2D ContactListener to check if my character is standing on the ground?

I want to know when my character is touching a wall or floor. I've had no luck searching for information on this. I saw a few things about ContactListeners and <...
2
votes
1answer
2k views

Camera scrolling and game boundaries

I am making a platformer game in JBox2D and LWJGL that has a scrolling camera, but I have hit a wall with the boundaries of the camera. Essentially what I have right now is a Box2D world that is ...
1
vote
0answers
1k views

Why won't my Box2d bodies collide? [closed]

I'm doing something wrong when trying to get bodies to collide using jBox2d & Slick2d. Here is have just my basic init, update, and render methods. Render and update seem to work fine for drawing (...
0
votes
2answers
896 views

How to translate from Slick2d coordinates to jBox2d

I read through this question to try and get a grasp on the topic, but I can't figure out how to apply this to my Slick2d window. I'm trying to do something as simple as place an edge on the bottom of ...
1
vote
1answer
478 views

Debug Render In Cocos2d Android

I want to implement debug render for cocos2d android.So I can view how bodies are created. Right now I use gdx.jar file for box2d and load that jar file following way. ...
3
votes
3answers
411 views

Box2D - Do these simple objects need to be in the simulation?

I would like to get input from the community regarding how best to represent simple objects in a Box2D based simulation. Some background: Without going into too much detail, think of a top down game ...
1
vote
1answer
486 views

2D js physics engine for HTML4

Is there any engine for Javascript like box2dweb that does not use Canvas? I need to build a game that works in HTML4 browsers.
0
votes
1answer
905 views

Box2D and Slick2D: Graphics bug [closed]

The bug The physics ground represented by a horizontal line. The object is stationary, and seems to be pretending that the ground is lower. This is because the center of the Shape is incorrectly ...
1
vote
2answers
6k views

Applying Forces to Box2D Bodies

In full disclosure, I am VERY new to box2D let alone the Java version of it. I have a box (here of type Hero) that I am trying to move. I did this by trying to apply a force as follows... ...
1
vote
1answer
375 views

OutOfBounds Exception when creating a PolygonShape using jbox2d

So here's the deal, i'm parsing a file that contains the vertices for a polygon, that i want to create in box2d. I create a new PolygonShape() and then call ...
6
votes
1answer
4k views

How to apply impulse to a body to make it fly away?

I'm playing around with jbox2d and can't really make a body "fly away" as if from an explosion. From what I have found on the net, making the body fly away from the world center (0,0), should have ...
0
votes
1answer
693 views

JBox2D - how to get vertex positions?

I've created a triangle for jbox2d... ...
4
votes
3answers
974 views

Why does creating dynamic bodies in JBox2D freeze my app?

My game hangs/freezes when I create dynamic bullet objects with Box2D and I don't know why. I am making a game where the main character can shoot bullets by the user tapping on the screen. Each touch ...