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

learn more… | top users | synonyms

-1
votes
1answer
73 views

Game crashes when trying to access function inside of a class, inside of a vector

So, I have a object, inside of a vector and I'm trying to call a function in that object : std::vector<Box>entities; entities.insert(entities.begin() +1, Box(&world, ...
-1
votes
1answer
76 views

Box falls extremely slow? (~1 pixel per second)

As the title says I have a problem where my box2d bodies falls extremely slow. Around 1 pixel per second. My world is stepped like this world.Step(1 / 60.0f, 8, 3);, each frame. The way I update ...
0
votes
1answer
22 views

Does all box2d bodies have collision detection?

What I want to know is if both b2-static and dynamic bodies have automatic collision detection. And how do I tell box2D what it should do when it collides with a specific body?
0
votes
1answer
65 views

Clearing memory from variables? [closed]

So, I've heard of the delete keyword, which clears variables that use the new or new[] keywords. I have a class called Box, which I made a object of in my main.cpp. What if I want to clear a ...
0
votes
1answer
47 views

How to unload/remove body components in Box2D?

I want to know how to release/clear/remove a variable. (specifically b2BodyDef, b2Body, b2FixtureDef, b2PolygonShape types.) I've heard there's a keyword called delete, guessing by it's name it may ...
0
votes
0answers
27 views

Libgdx Box2D - Object not showing up

I am trying to put a sprite into my b2d-world. But for some reason, it is not showing up. I've already checked the camera settings, they are defenetly correct. Then I came to the point to check the ...
3
votes
1answer
184 views

How to implement rotating rectangle around circle in libGDX Box2D?

I want to implement rotating rectangle around cicrle in such way, that circle has no rotation, and rectangle has, and I could myself control rotation of this rectangle (I mean set its angular ...
0
votes
2answers
101 views

sf::RectangleShape's position is not same as I set it to

When I try to print my box.getSfShape()'s position it does not print out the position I set it to have. ( The box.getSfShape()'s position is by default set to 0 ) Wrong output : ( printing the ...
2
votes
1answer
217 views

Why do my Box2D bodies not fall, even though world.step is called?

I have SFML set up with a Box2D world that has gravity, but my bodies won't move. I std::cout'ed the position of the body in the game loop, but it's always at (0, 14)! No errors or warnings, just no ...
2
votes
1answer
43 views

Call function via ContactListener

I've been creating a game on my own in LIBGDX, BOX2D and there' s a problem I can' t solve. When two World bodies collide, method "beginContact" is called in MyContactListener class that implements ...
0
votes
0answers
52 views

Rendering BOX2D shapes with LIBGDX

I have been creating a game on my own and I need a little help to begin with graphics. I haven' t found much in the internet about this topic, so I came here. Right now I've got a chainshape that i'm ...
0
votes
0answers
29 views

Touch and Collisions not working together in AndEngine when i set a custom Physics Handler

I have a set of custom sprites which implement a custom physics handler. The aim is to allow the user to move them by touch, then upon release they should act like a spring is connecting them to the ...
0
votes
1answer
125 views

How do i set gravity towards a point in the centre in AndEngine with Box2D?

I have a scene and i can set gravity in the PhysicsWorld like this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, -SensorManager.GRAVITY_EARTH),false); but i would like all bodies to gravitate to ...
0
votes
2answers
83 views

Libgdx change to other screen and dispose current one

I am trying to switch to a GameScreen when the LinearVelocity of a Box2D - Object is x = 0. If it is so, I am using the setScreen() - Method by calling the main class. This works perfekt, but when ...
0
votes
0answers
54 views

Trying to get Box2D bodies to fall [SFML, Box2D, C++] [duplicate]

As the title says I'm trying to make my Box2D body to fall, but it won't work. It just stays at the same position. Sorry for the long codes but I have no idea where I'm doing something wrong, so I ...
-2
votes
1answer
91 views

Is it possible to use Box2D or Chipmunk in Swift & Cocos2d?

I am new to iOs programming. I wonder whether it is possible to use Box2D physic engine in Cocos2D with Swift. I am asking because I started to learn Swift. And I create Xcode project from ...
3
votes
1answer
127 views

Creation of a tiled map editor polyline in box2d is not working correctly

I'm currently trying to create a box2d polyline object in my libgdx game, but it's not working as expected. To get a better picture of my subject, have a look at how it should look like, and how it ...
3
votes
1answer
135 views

Data oriented design in physics engine

I am new to data oriented design and I am currently developing a physics engine as a hobby project. I am really interested in data orinted design but I am not sure how to apply data oriented design to ...
3
votes
1answer
146 views

LibGdx 2d Free-Form Terrain

I have a query about how to create a 2d landscape level using libgdx/ box2d (Or possibly with Unity) for Android and iOs. Let me describe the goal and then the specific points I need help with. What ...
1
vote
0answers
21 views

LibGDX: Box2d hovering, rotating body

Hello I am working on a hovering triangle (equilateral triangle). The triangle should allways rotate at a constant speed and hover over the ground. The problem is if I setAngularVelocity it does rise ...
4
votes
1answer
83 views

How to spawn Chunks in Libgdx?

I'm currently working on a 2D platforming game with an infinite map. I did my research and I discovered that I can use chunks. Based on my understanding chunks is about spawning terrain at the right ...
4
votes
0answers
161 views

Ledge climb animation and movement (2d platformer)

Struggling to make a decision on the implementation of a ledge climb mechanic for a physics driven 2d platformer. What is the best way to go about this without it getting overly complex? So far I ...
3
votes
1answer
41 views

Box2d: Is there a way to have collisions but ignore the accompanying forces?

To begin, I know that you can use filtering or isSensor to remove physical collisions. However, I would like to retain the ability to, say for example, stop when trying to move past another player. ...
1
vote
0answers
61 views

2D Physics library for multiplayer in c++ [closed]

Im trying to create a top down shooter with multiplayer functionality. So far im using Box2D for my physics Simulation. The last few days I played around with syncing movement between Clients and ...
2
votes
0answers
59 views

Get a body from TiledMap via MapBodyBuilder and draw a sprite on it in LibGDX?

I use a various of MapBodyBuilder in my Libgdx project. I created a body from map.tmx via my MapBodyBuilder and in my SpriteBuilder buildSprite method i created its sprite: sprite = new ...
1
vote
0answers
61 views

How to disable static friction in Box2D?

I'm making a 2D platformer. One of the issues is that when the character hits the ground, there's an initial pause and then the character finally slows down to a halt. I believe the initial pause is ...
2
votes
0answers
51 views

Moving and rotating to a position with forces and impulses [closed]

Carrying on from this question, I'm still stuck trying to implement the behaviour mentioned in this tutorial. My movement has improved slightly thanks to the help I received: But the character ...
1
vote
1answer
89 views

In Box2D, how can I SetTransform of a body without getting an IsLocked assertion error?

I've created a bullet body and stored a reference to it in herobody: bDef.type = b2_dynamicBody; bDef.position.Set(herobody->GetPosition().x, herobody->GetPosition().y); b = ...
1
vote
1answer
44 views

set sprite to current animation texture

In my game I have some box2d bodies where I add sprites using the following code in my render() method. for (Body body : worldBodies) { if (body.getUserData() instanceof Sprite) { ...
5
votes
2answers
129 views

How do I turn an image into a Box2D physics object?

I'm using Box2D for a Game Programming course, and I was wondering if it is possible to choose the best shape and size of shape for the rigidbody/fixture for a sprite based on its transparency. I've ...
0
votes
0answers
19 views

Box2D revolute joint positioning

I'm trying to auto test some basic assumptions about how bodies tied together with a revolute joint should be positioned: void tst_GameController::physicsJointInitialPosition() { ...
2
votes
0answers
65 views

Rotating kinematic object around a moving point Box2D

I'm new at Box2D and I am making a simple game where you control the rotation of the maze and the gravity leads the ball to the exit. The game looks like: The problem: I want to rotate the maze, ...
1
vote
1answer
319 views

Soft Body Collision with Box2d (libGDX)

I've made a few classes to create soft body objects in libGDX using Box2D (specifically a circle and rectangle similar to these links). The objects are constructed of a number of circle shaped Box2D ...
0
votes
1answer
80 views

Drawing the box2D rectangles

i'm using SDL2.0/OpenGL + Box2D with C++ to learn some stuff about games, so i created two rectangles bodies: a small box(dynamic) wich will fall into the second body: the ground(static), i draw them ...
0
votes
1answer
31 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. ...
0
votes
1answer
225 views

LibGDX: Issue with unitScale for Tiled and Box2D

I've got the following: I use a TiledMap (loaded from a .tmx), each tile 32x32 pixels in size and generate the Box2D bodies for collision from the TiledMap's ObjectLayer. That all works fine, no ...
1
vote
1answer
39 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
vote
1answer
52 views

dynamic body jumping out of water object

In my game I have my main object, a jetski, which will dive down into water, when the screen is touched. I managed to code the jetski diving down, with Box2d and some buoyancy forces. But when the ...
1
vote
2answers
37 views

applyForce as long as display is pressed

In my project I have my main character body. I want it to move down on the y-axis as long as the screen is pressed. I tried it with public boolean touchUp(int screenX, int screenY, int pointer, int ...
3
votes
1answer
39 views

In Box2D, what exactly does a fixture represent?

In Box2dWeb, when we create a body we attach a fixture to the body object. We make the shape, friction, restitution and so on by tinkering with the fixture object. So from this can we conclude that ...
0
votes
1answer
88 views

Black screen when launching on phone

I am coding a game in libgdx. While adding the background I used the html module to watch the results fast and easy on my computer. But when I try to see it on my phone I just get a black screen. My ...
1
vote
2answers
56 views

Camera controll in Libgdx

I've a condition in my game where, I want my camera to follow the Player(its a body from Box2d) and in some not. This is the start screen of my game: Now, when i press a button(space) the player ...
0
votes
1answer
70 views

TypeError: R[o5R.F6s] is not a function in changing states in phaser box2d

i build my game using phaser.2.4.3.min.js and phaser.2.2.2.box2d.min.js When trying to change states this error is being raised TypeError: R[o5R.F6s] is not a function and i can't seem to figure out ...
5
votes
1answer
552 views

Why do my game objects jitter when moving the camera?

I'm moving from Qt Widgets' QGraphicsScene to Qt Quick's QQuickItem for rendering my game objects. One of the things this involves is setting up a scene and the view onto that scene, as this was ...
0
votes
0answers
19 views

DynamicBody diving into StaticBody

In my game I want a DynamicBody to dive down into a StaticBody. I set up both bodies. At the moment they are colliding. How can I get my DynamicBody to dive down? Is it going to work with this ...
0
votes
1answer
34 views

Box2d Coordinate System

In the game I'm trying to code I got to have two bodies. One StaticBody and one DynamicBody. I want to have the DynamicBody on top of the StaticBody. Somehow all I get is this: Is it possible that ...
1
vote
1answer
77 views

Box2d jetski on water

At the moment I am trying to code a 2d game in java, where a jetski is riding on water. If you press on the screen the jetski should dive down and jump back up on release. How do I have to do this in ...
2
votes
1answer
82 views

Viewport and Camera setting

For my first game in LibGDX and Android I got a Problem: I have a background picture which is 2560px * 720px. The screen is 1280 * 720. How do I have to set the viewport and camera in order to get ...
1
vote
0answers
35 views

Model a helium balloon on Box2D + libgdx [closed]

I want to make so that the bigger the balloon is, the faster it goes upwards, and if it's not big enough it will fall down. I tried applying a force greater than the gravity but it doesn't work as I ...
1
vote
3answers
253 views

Collision Detection/Response Issues in Unity

Sprite A: Box Collider 2D and Rigidbody 2D. Sprite B: Box Collider 2D. Both sprites have a Sprites/Default material with Pixel Snap enabled. The textures being used are set to Truecolor Format and ...