I have a box2d world with the view locked into landscapeLeft. I'm trying to move a body by tilting the phone left or right, which is currently working. I have problems when the level is started with the phone tilted in landscapeRight. under this condition the gravity is no longer being applied, and my body which should be moving stands still. I believe this is a friction issue (even though both my body to move and platform to move on are both 0 friction), because when I set the restitution of the platform my body is resting on to 1.0 (so my body is now bounding a little in place) the gravity is applied correctly always. This is not the box2d issue where bodies get stuck on corners of tiles as I only have 1 platform for my body to move on, and it does not move no matter where it is on the platform. here is my acceleration code.
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate (UIAcceleration*)acceleration
{
if (acceleration.x < 0) {
b2Vec2 gravity(-acceleration.y * 15, -8);
world->SetGravity(gravity);
}
}
here is my init code
// Define the gravity vector.
b2Vec2 gravity;
gravity.Set(0.0f, -10.0f);
// Do we want to let bodies sleep?
// This will speed up the physics simulation
bool doSleep = true;
// Construct a world object, which will hold and simulate the rigid bodies.
world = new b2World(gravity, doSleep);
world->SetContinuousPhysics(true);