Hi,
This is the first time using Box2D, so please forgive me if I may not fully understand some concepts.
I'm trying to fit my world to the iPhone screen of 320x480, but I'm having some problems.
I'm creating my world boundaries using the following code:
Code:
#define PTM_RATIO 32.0f
// 320x480
CGSize screenSize = self.view.bounds.size;
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0, 0); // bottom-left corner
b2Body* groundBody = world->CreateBody(&groundBodyDef);
b2EdgeShape groundBox;
// bottom
groundBox.Set(b2Vec2(0,0), b2Vec2(screenSize.width/PTM_RATIO,0));
groundBody->CreateFixture(&groundBox, 0);
// top
groundBox.Set(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO));
groundBody->CreateFixture(&groundBox, 0);
// left
groundBox.Set(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(0,0));
groundBody->CreateFixture(&groundBox, 0);
// right
groundBox.Set(b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,0));
groundBody->CreateFixture(&groundBox, 0);
However, when viewing it on the iPhone simulator, the world seems be offset from the UL corner
about 200 pixels or so:
Screenshot:
http://imageshack.us/photo/my-images/69/box2diphone.png
Changing PTM_RATIO does not help. The offset still stays in the same place.
How can I fit my Box2D world to the iPhone boundaries of 320x480?
Thanks.