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
5
votes
4 answers

Is there a way in Box2dWeb to output position.x of an object to console.log()?

I am thinking there is a simple answer to my seemingly simple question but I could be totally wrong. Anyway I am new to box2dWeb and in my Box2dWeb world I create a floor and a simple falling object. When I "debug draw" into my canvas I see the box…
Stankyfist
  • 111
  • 1
  • 7
5
votes
1 answer

How do I make water as seen in Sea Stars?

There is a nice Sea Stars iOS application out there, with a good looking water effect can be seen on video. I have found Tiny Wings "waves" tutorial on here, so I guess I can figure out how to make waves. I wonder how do I make effect when hero pops…
Dennis Krut
  • 423
  • 1
  • 6
  • 11
5
votes
2 answers

Detect initial collision of two box2d bodies without continuous collision

I have some simple box2d bodies setup with a contact listener like so: #import "MyContactListener.h" MyContactListener::MyContactListener() : _contacts() { } MyContactListener::~MyContactListener() { } void…
Alex
  • 1,322
  • 1
  • 20
  • 44
5
votes
1 answer

Moving Box2d Bodies Like CCSprite Objects

In cocos2d, you can ease in CCSprites and move them around in all kinds of ways. Most importantly - they can have easing in/out. For most games this is desirable for smooth movement etc. id action = [CCMoveTo actionWithDuration:dur…
Aram Kocharyan
  • 20,165
  • 11
  • 81
  • 96
5
votes
1 answer

Create a random, sine graph like landscape sprite

Lets say I have this sprite: And I created a random landscape during runtime: And then, I want to tile the area below the line with the sprite: This is the game ground, therefore it should also be a physics object (In Box2D). Here, he given a…
Jong
  • 9,045
  • 3
  • 34
  • 66
5
votes
4 answers

Preventing box2d player from pressing against walls in midair

I have setup a box2d world with a keyboard controlled player. The player can walk and jump. How do I prevent the player from "sticking" to walls while jumping and pressing the directional key towards an object?
Mattias
  • 3,907
  • 4
  • 28
  • 50
5
votes
3 answers

How do I draw my Box2D world using HTML5 Canvas instead of Debug Draw?

I know HTML5 canvas fairly well, I know the basics and animation using loops etc. Demo I'm working with: (click to make shapes) http://henry.brown.name/experiments/box2d/example-canvas.html What I'm not very familiar with is Box2D. I'm using the…
Sabai
  • 1,579
  • 5
  • 24
  • 40
5
votes
2 answers

How to implement bullet time in Box2d?

I want to implement some sort of bullet time for my box2d app, googling around I found a post were they suggest to change the timestep (something like from 1/30 to 1/60) but its quickly flagged as bad practice, all I need is a basic on/off trigger…
Ricardo Sanchez
  • 4,935
  • 11
  • 56
  • 86
5
votes
1 answer

AndEngine Sprite/Box2D Body removal crashes my program with no error/exception information?

I am making a skateboarding game with obstacles you have to jump over using box2D and AndEngine. I am trying to make it so that when the player collides with an object, the object is removed and an explosion is placed at the objects old position,…
AndroidNoob
  • 2,771
  • 2
  • 40
  • 53
5
votes
1 answer

Performance issues with large static edges terrain in Box2D

I'd like to support very large worlds in the game that I'm making. This is not a problem usually, because I can cull most of the world as it is not visible all at once. However, Box2D doesn't seem to like my idea! My terrain currently consists of…
Hero
  • 51
  • 2
5
votes
1 answer

A circle changes its direction when exactly between two squares

I have a Box2D world with circles representing pedestrians and squares representing buildings, I have an algorithm which finds the nearest building and then it will turn at the edge but I have a problem that it will turn when it is exactly in the…
Mechatrnk
  • 101
  • 1
  • 13
5
votes
1 answer

How would I build Box2D to work in Code::Blocks/Mingw32(Windows)

hey the title pretty much says it all. i have been trying different methods from internet sources, but whenever i try something goes wrong..this is where i got Box2D in cMake, i get a bunch of errors when building it(i was going through the steps in…
Molmasepic
  • 1,015
  • 2
  • 13
  • 18
5
votes
3 answers

How do I get a Hero physics body to calmly rest on a moving platform physics body?

My game has a Ferris Wheel with 4 seats. Each seat has a platform that the hero can rest on. When the seat is on the upward trajectory the hero calmly stays on the platform. However, when the seat is on the downward trajectory the Hero moves…
josh k
  • 268
  • 1
  • 11
5
votes
1 answer

Java and Box2D - Which body should be treated as a bullet?

I am creating a game using java and box2D (from libgdx). At this moment I have a problem, when the red body of the image bellow falls, sometimes it does not hit the platform (that is also a dynamic body) because it falls with a high amount of speed…
Daniel Oliveira
  • 1,280
  • 14
  • 36
5
votes
5 answers

Box2D rotate an object, how?

How I can rotate an object in Box2D? Tried.. private static final double DEGREES_TO_RADIANS = (double)(Math.PI/180); float angle = (float) (45*DEGREES_TO_RADIANS); object.body.setTransform(object.body.getPosition(), angle); ..but not working.
lacas
  • 13,928
  • 30
  • 109
  • 183