i have went through the api sample (below)
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 }
)
================================================================
and i am planning to put all the setup into a setup.lua file, which contain all physic object setup
and in main.lua, i should be able to call
main.lua
physics.addBody( myBody[index], myBody[index].bodyType,
myBody[index].elementSetup
)
setup.lua
myBody[index].elementSetup = "dynamic"
myBody[index].bodyType = {
{ 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 i am hitting compile error for code above.
I am quite new to lua can some lua master tell me, how suppose the two portion of code should be?
Thanks for the guide [import]uid: 10373 topic_id: 3755 reply_id: 303755[/import]