Yes, you simply define the shape with a table of x,y coordinates in clockwise order, centered around 0,0. So a 20 pixel square shape would be defined like:
squareShape = {-10,-10,10,-10,10,10,-10,10}
8 points in the maximum, so your shape table would have 16 numbers, 2 for the x,y of each point. Since you’re probably trying to fit the shape to an image it might be easier to load the graphic in Photoshop and turn the “info” panel on to find the correct coordinate spacing.
Then just apply that shape to the body:
physics.addBody( boxThing, “static”, { density=1.6, friction=0.5, bounce=0.2, shape=squareShape } )
Some 3rd party tools let you trace an image and output the shape data, and some will create multiple shapes for objects with “complex bodies” (There are cases where 8 points is not enough, so you break the object up into multiple shapes that fit together and apply them all to the body).
Sure,you can do all that without a 3rd party tool, using graph paper and perhaps a calculator, but that can get time consuming and error prone if you have more than a couple simple shapes.
[import]uid: 9422 topic_id: 14052 reply_id: 51823[/import]