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

Best way to change shape of a 4-sided polygon?

Topics: User Forum
Jan 12, 2011 at 11:20 PM
Edited Jan 12, 2011 at 11:21 PM

Hi everyone. 


I have a list of rectangular fixtures.  I need to occasionally iterate through the list, disable each one, change their shape, and re-enable them.  They'll still be rectangular polygons after the change, but I need to change their height & width.  So how can I change the shape exactly?  I don't want to generate garbage...  Is they a way to just re-assign the four vertices in each fixture to get the new shape?  Or, is there a way to just give each fixture a new shape object, without generating garbage from abandoning the old shapes (I'm assuming that's what would happen)?

Jan 15, 2011 at 9:23 PM

you can cast the shape to a polygonshape if you created it using vertices in the first place. Then I think that you can iterate through the verticies and create a new one that you then would assign to the old vert. I also think that reasigning the body should be ok as long as you just reinitialize it, then you wont generate garbage.