box2d

How would you keep a top view of a train on the tracks with the Box2D physics engine?

I think it would be fun to model a top view of a train following a track, traversing switches and so on, using a physics library like Box2D. What joints and motors would I need to make this work? I'm curious about how to implement the forces needed to make the car follow a spline track so it can bump into other train cars, pedestrians, ...

Constant speed for wheel of any radius when setting speed in radians per second?

In box2d physics engine I can set a motor speed for a joint on my wheel in Radians/Second. What would be an expression I could set the speed to so the final actual "speed" of the wheel would be the same regardless of wheel radius. Presently, I'm setting the Wheel speed as a constant, wheelSpeed = 20. But this has the effect of making...

Box2D: How to detect an object no longer collide with another object?

Flash Box2D Question (But I guess the "flash" part doesn't matter) Suppose there is an object A, which is the character and an object B, which is the ground Suppose the character can only walk when he touches the ground. There is a box 2d contact listener, which I can detect when an object touches another objects, so I can use it to l...

How to calculate load bearing in Box2D?

I'm using Box2D (the AS3/Flash version, if it matters) and I'm trying to calculate how much weight each body is carrying. I know how to iterate through all the bodies, and I know how to poll the Collion Detection routines, but it seems the collision forces die off to zero once weight is applied. Is there some sort of "total static force...

How to create a wrapping world in Box2D

Hi, I need to create an endless wrapping world with Box2D (where the X coordinate of all objects is 0 < X < 1000 (say)). I've played some games with teleporting objects back and forth but it's feeling like there might be a better way - any ideas? No object (or chain of linked objects) will have an X span of more than about 50, eg less t...

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) ? ...

box2d edgeshape collision groups ignored

I added collision groups to my game and they are working fine except with concave shapes (Edge Shapes). It seems that they ignore them completely. When I don't use a contact filter and collision groups the collision works. ...

Would Apple reject an app from the iphone app store for using box2d?

I am contemplating using Box2d for making iphone apps, but I don't want to worry about Apple rejecting my app for using Box2d. How does box2d work? http://www.box2d.org/ Would Apple somehow reject for using this engine? I think I remember someone saying that they have rejected for using 3rd party dlls/etc... ...

Best way to deal with object that can't instantiate itself?

I guess I've asked a few similar questions before, but I was beating around the bush. I think this is the real problem that I can't quite lay to rest. I'm dealing with a third party library, and there's an object that can't create itself, b2Body. The b2World has to instantiate it. I personally don't like this design pattern very much; I...

Guide for Cocos2d and Box2d on iphone?

I'm new to the world of game programming but wanted to build a simple physics-based game for the iPhone. Does anyone know of any tutorials for Cocos2D and/or Box2D on the iPhone? The documentation is kind of confusing. ...

Box2d Documentation - Outdated, any better api refs?

Hi guys, I am working with cocos2d + box2d and as I look through the 'Hello World' tutorial and attempt others I am finding many constructs which do not seem to be documented in the latest api ref. Would anybody be able to shed some light on what's going on? or point me in the right direction to someone who has covered the new construc...

How do I create a floor for a game?

I'm attempting to build a Lunar Lander style game on the iPhone. I've got Cocos2D and I'm going to use Box2D. I'm wondering what the best way is to build the floor for the game. I need to be able to create both the visual aspect of the floor and the data for the physics engine. Oh, did I mention I'm terrible at graphics editing? ...

Impossible to inherit from this object?

Following up on this question, people have suggested I go with "option 3" which might look like this: class b2Body { private: b2Body() {} friend class b2World; }; class Body : public b2Body { private: Body() {} friend class World; }; class b2World { public: b2Body *CreateBody() { return new b2Body; } }; class World : public b...

Falling object in Box2D should rotate due to centre of mass?

I'm trying to simulate a falling balloon in Box2DAS3. What is important is that balloon falls the such that the bottom part were you blow it up rotates towards the bottom if it's knock sideways or is dropped at an angle. I've tried offsetting the center of mass of the body and also joining two bodies together with the denser one repre...

Box2d: mousejoint without inertial delay

I'm using mousejoint to drag bodies in box2d, but it causes inertial delay. Does it exist any way to drag a body instantaneously? ...

box2d: bigger clickable/touchable area

I'm using Box2D on my iPhone app using Cocos2D. I'm using mouse joint to drag objects by touch. The touch event is handled to find the corresponding Box2D body using AABB queries. I would want to extend the area of Box2D bodies. In this way, I can touch approximately my body and still respond. Does it exist any way to do this? Thanks...

Box2D body position always (0,1) on spawn

I'm creating a b2BodyDef with the position set to (10,10). Then I run world->CreateBody(&shDef); but the b2Body is created at position (0,1). How can I fix the body creation so that it spawns at the desired location? I know the body is in the wrong place because: A. The rendering system isn't rendering it in the right place B. Print...

Box2D Walls - same code: the left one works, the right one doesn't

I'm making a simple Box2D game ( http://iwanttobeacircle.com ), where you start off as a triangle and bounce off bigger shapes to gain sides. I'm having a bizarre bug with my walls... both are created from the same class, yet the left one works and the right doesn't. If I only add the right one, then it works, but for some reason adding...

Cocos2d + Box2d or Chipmunk

OK, im trying to make an iphone version of a game i made here http://scratch.mit.edu/projects/techy/781198 is box2d or chipmunk better and where are some tutorials for each one ...

GetBodyCount() always returning 0 in Box2d?

Hi There, I am using the cocos2d-iphone + Box2d engine, I have a simple call in Box2d to create a body: b2Body *crateBody = world->CreateBody(&crateBodyDef); Then I am printing the newly incremented body count variable through: CCLOG(@"There are %0.0f bodies in the world.", world->GetBodyCount()); However, GetBodyCount() always re...