This project has moved. For the latest updates, please go here.

Gap within body

Topics: Developer Forum
May 6, 2011 at 1:53 AM
Edited May 6, 2011 at 1:58 AM

Hello. I have a body and was wondering if it's possible to create a gap within the body at a certain point, programmatically? For example, I have a square and create a gap 5 units tall, in the middle of the square (going right across). Anything that collides with the remaining top or bottom half will bounce back, but if it goes through the gap, then no collisions occur. Is there a way of doing this?

May 6, 2011 at 3:33 PM

You could make a Body and then use the FixtureFactory to attach two Rectangles.  If you make the rectangles the correct size and position them so one is on the top portion and one is on the bottom portion you'll get what you want.  That is if I understood you correctly.

A body can have any number of fixtures.  The fixtures are what control collisions... so if you want a gap, just don't have a fixture there.