As above, how can I create a hollow square physics box?
Like the grey part of the square below.
As above, how can I create a hollow square physics box?
Like the grey part of the square below.
https://docs.coronalabs.com/api/library/physics/addBody.html
check this out scroll to the bottom and try some of that stuff. like thr multiememnt bodies and etc.
hope this helps!
Tyler Jacobson
I’ve tried it before, however I’m still stuck with these lines
local podT = {1,-89, 14,-83, 20,-70, 14,-57, 1,-51, -12,-57, -18,-70, -12,-83} local podR = {69,-20, 82,-14, 88,-1, 82,12, 69,18, 56,12, 50,-1, 56,-14} local podB = {1,49, 14,55, 20,68, 14,81, 1,87, -12,81, -18,68, -12,55} local podL = {-70,-20, -57,-14, -51,-1, -57,12, -70,18, -83,12, -89,-1, -83,-14}
Got no luck with the numbers…
Hi @gamerheaven213,
Can you show the rest of your code, i.e. how you’re using those coordinate tables in the actual physics body creation?
Thanks,
Brent
you could use four offset rects. personally, i’d rather use four trapezoids, fe:
local rect = display.newRect(x,y,M\*2,M\*2) -- or newImageRect, whatever local body1 = {shape={ -M,-M, M,-M, m,-m, -m,-m }} local body2 = {shape={ m,-m, M,-M, M,M, m,m }} local body3 = {shape={ -M,M, -m,m, m,m, M,M }} local body4 = {shape={ -M,-M, -m,-m, -m,m, -M,M }} physics.addBody(rect, "static", body1, body2, body3, body4)
define “M” to be half your major width/height (outer square), and “m” as half your minor width/height (inner hole)
https://docs.coronalabs.com/api/library/physics/addBody.html
check this out scroll to the bottom and try some of that stuff. like thr multiememnt bodies and etc.
hope this helps!
Tyler Jacobson
I’ve tried it before, however I’m still stuck with these lines
local podT = {1,-89, 14,-83, 20,-70, 14,-57, 1,-51, -12,-57, -18,-70, -12,-83} local podR = {69,-20, 82,-14, 88,-1, 82,12, 69,18, 56,12, 50,-1, 56,-14} local podB = {1,49, 14,55, 20,68, 14,81, 1,87, -12,81, -18,68, -12,55} local podL = {-70,-20, -57,-14, -51,-1, -57,12, -70,18, -83,12, -89,-1, -83,-14}
Got no luck with the numbers…
Hi @gamerheaven213,
Can you show the rest of your code, i.e. how you’re using those coordinate tables in the actual physics body creation?
Thanks,
Brent
you could use four offset rects. personally, i’d rather use four trapezoids, fe:
local rect = display.newRect(x,y,M\*2,M\*2) -- or newImageRect, whatever local body1 = {shape={ -M,-M, M,-M, m,-m, -m,-m }} local body2 = {shape={ m,-m, M,-M, M,M, m,m }} local body3 = {shape={ -M,M, -m,m, m,m, M,M }} local body4 = {shape={ -M,-M, -m,-m, -m,m, -M,M }} physics.addBody(rect, "static", body1, body2, body3, body4)
define “M” to be half your major width/height (outer square), and “m” as half your minor width/height (inner hole)