Box2D Forums

It is currently Mon May 20, 2013 12:45 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Mar 08, 2012 3:05 pm 
Offline

Joined: Thu Mar 08, 2012 2:56 pm
Posts: 3
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);


Top
 Profile  
 
PostPosted: Thu Mar 08, 2012 3:59 pm 
Offline

Joined: Thu Mar 08, 2012 2:56 pm
Posts: 3
yeah, i just realized I was doing Y,X instead of X,Y


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group