I’ll try to keep it very simple:
I’m messing around with some 2d landscapes, mountains and such. Because of the complex shapes, i actually generated multiple shapes that can be used together to simulate one very complex body. (As you know physics shapes are limited to 8 points or sides)
This part is all good, and i know you can create one body out of it like this:
----stolen from docs----
local car = display.newImage(“big_red_car.png”)
roofShape = { -20,-10, 20,-10, 20,10, -20,10 }
hoodShape = { 0,-35, 37,30, -37,30 }
trunkShape = { 0,-37, 37,-10, 23,34, -23,34, -37,-10 }
physics.addBody( car, “dynamic”,
{ density=3.0, friction=0.5, bounce=0.2, shape=roofShape },
{ density=6.0, friction=0.6, bounce=0.4, shape=hoodShape },
{ density=4.0, friction=0.5, bounce=0.4, shape=trunkShape }
)
but my shapes are all in one table, like this:
shapes = {
{-20,-10, 20,-10, 20,10, -20,10 }
{hoodShape = { 0,-35, 37,30, -37,30 }
{trunkShape = { 0,-37, 37,-10, 23,34, -23,34, -37,-10 }
}
Is there a way to pass all these subtables as arguments to the addBody function somehow? I cannot predict how many there will be at runtime, so i’m kind of lost
I hope i didn’t overcomplicate things, please tell me if i did
Any help would be much appreciated! =) [import]uid: 7980 topic_id: 2055 reply_id: 302055[/import]
[import]uid: 7980 topic_id: 2055 reply_id: 6018[/import]