I'm working on an iPhone game, and the ground is a long, repeating rectangular sprite object that extends about 30 pixels above the bottom of the screen. I'm trying to align my ground edge shape 30 pixels so it when the player sprite lands on the ground from a jump, he will land on top of ground image. When I tried adding the following code, it didn't work:
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0, 30/PTM_RATIO);
b2Body *groundBody=world->CreateBody(&groundBodyDef);
b2EdgeShape groundLine;
groundLine.Set(b2Vec2(0, 30/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO, 30/PTM_RATIO));
groundBody->CreateFixture(&groundLine, 0);
I realize I could probably use a rectangle shape for the ground, but since my player sprite is only colliding with the top of the image, I would rather get away with an edge shape.