I'm trying to create a wall around my play area, the play area is an area in meters (mapped to real world coordinates), which is, at this point, a rectangle with the following coordinates:
Code:
Top = 1.5
Bottom = 3
Left = -0.75
Right = 0.75
But the final numbers aren't important right now. The rectangle is in the
screenArea variable in the code below.
I'm trying to set up a wall around the screen area, does the code below do that? It's not working, and I'm thinking it might have something to do with the fact that 0,0 isn't within the area.
Before, I was making the wall between (0,0) and (Width, Height) and it worked OK, but I needed to offset my sprites and do some very unnatural (and I think unnecessary) coordinates juggling.
Code:
// set up wall
b2Vec2 vs[4];
vs[0].Set(screenArea.Top, screenArea.Left);
vs[1].Set(screenArea.Bottom, screenArea.Left);
vs[2].Set(screenArea.Bottom, screenArea.Right);
vs[3].Set(screenArea.Top, screenArea.Right);
b2ChainShape bShape;
bShape.CreateLoop(vs, 4);
b2FixtureDef fDef;
/*
fDef.filter.categoryBits = 0x02;
fDef.filter.maskBits = 0x04;\
*/
fDef.shape = &bShape;
fDef.density = 100.f;
// walls
bDef.position.Set(0,0);
walls = world.CreateBody(&bDef);
walls->CreateFixture(&fDef);