How to get a physics shape centered around certain coordinates?

I am trying to make something where you tap and it spawns a triangle. I have to use display.newPolygon to make the display triangle. The display coordinates are centered around event.x and event.y, but the physics coordinates are off. The physics body is still the same shape, though. Is there a way to make the physics coordinates act the same way as the display coordinates, and if not, is there some clever mathematical way to do that?

You can do the math yourself or use the following tools

–Physics Body Editor

Pros: Free, Mac and Pc, Easy to use

Cons: Somewhat hard to install, Stopped Updating (as far as I know)

https://forums.coronalabs.com/topic/60272-physic-body-editor-plugin/

–Corona Composer Gui

Pros: Free, Already Built in to lastest version (only Mac), Easy to use, Other Tools

Cons: Not as seamless as it should be, Mac Only, Stopped Updating (as far as I know), Only 8 Joints allowed

https://coronalabs.com/products/composer-gui/

– Physics Editor

Pros: Easy to use, Mac and Pc, Seamless to integrate

Cons: 20$ (30 day trial and 1 year of use)

https://www.codeandweb.com/physicseditor

– Level Helper Editor

Pros: Easy to use, Seamless to integrate, Good Tutorials, Other Tools

Cons: 25$ (30 day trial and 1 year of use), Mac Only

http://www.gamedevhelper.com/

Edit: Also you should be to just use your display coordinates in addBody

for example:

local cords = { 25, -25, 25, 25, -25, 25 } local myObj = display.newPolygon( 50, 50, cords ) physics.addBody(myObj , "static", { density = 200, friction = 200, bounce = 2, shape = {cords })

scottrules44, I made the physics bodies, and they are the correct shape, but are slightly off set from the display object. The physics body is fine, it’s the positioning that’s off.

Screen shot: https://drive.google.com/open?id=0B3yZxOkbSdz7MXBHUWhTbGtBcHc 

I cannot see the screenshot

I may be due to your display group. Some code might be helpful

Yeah I just clicked the screenshot and it won’t show up for me either. Take 2: 

Here’s the entire code of the triangles: 

function onTap( event ) red = math.random() blue = math.random() green = math.random() width = math.random(10,100) height = math.random(10,100) fric = math.random() dense = (width + height)/200 boing = math.random() triVert1X = math.random(-50, 50) triVert1Y = math.random(-50, 50) triVert2X = math.random(-50, 50) triVert2Y = math.random(-50, 50) triVert3X = math.random(-50, 50) triVert3Y = math.random(-50, 50) triVerts = {triVert1X, triVert1Y, triVert2X, triVert2Y, trivert3X, triVert3Y} triDense = (triVert1X + triVert2X + triVert3X) / 300 local tri = display.newPolygon(event.x, event.y, triVerts) tri:setFillColor(red, green, blue) physics.addBody(tri, {friction = fric, density = triDense, bounce = boing, shape = triVerts}) physics.setDrawMode("hybrid") end Runtime:addEventListener( "tap", onTap )

You can do the math yourself or use the following tools

–Physics Body Editor

Pros: Free, Mac and Pc, Easy to use

Cons: Somewhat hard to install, Stopped Updating (as far as I know)

https://forums.coronalabs.com/topic/60272-physic-body-editor-plugin/

–Corona Composer Gui

Pros: Free, Already Built in to lastest version (only Mac), Easy to use, Other Tools

Cons: Not as seamless as it should be, Mac Only, Stopped Updating (as far as I know), Only 8 Joints allowed

https://coronalabs.com/products/composer-gui/

– Physics Editor

Pros: Easy to use, Mac and Pc, Seamless to integrate

Cons: 20$ (30 day trial and 1 year of use)

https://www.codeandweb.com/physicseditor

– Level Helper Editor

Pros: Easy to use, Seamless to integrate, Good Tutorials, Other Tools

Cons: 25$ (30 day trial and 1 year of use), Mac Only

http://www.gamedevhelper.com/

Edit: Also you should be to just use your display coordinates in addBody

for example:

local cords = { 25, -25, 25, 25, -25, 25 } local myObj = display.newPolygon( 50, 50, cords ) physics.addBody(myObj , "static", { density = 200, friction = 200, bounce = 2, shape = {cords })

scottrules44, I made the physics bodies, and they are the correct shape, but are slightly off set from the display object. The physics body is fine, it’s the positioning that’s off.

Screen shot: https://drive.google.com/open?id=0B3yZxOkbSdz7MXBHUWhTbGtBcHc 

I cannot see the screenshot

I may be due to your display group. Some code might be helpful

Yeah I just clicked the screenshot and it won’t show up for me either. Take 2: 

Here’s the entire code of the triangles: 

function onTap( event ) red = math.random() blue = math.random() green = math.random() width = math.random(10,100) height = math.random(10,100) fric = math.random() dense = (width + height)/200 boing = math.random() triVert1X = math.random(-50, 50) triVert1Y = math.random(-50, 50) triVert2X = math.random(-50, 50) triVert2Y = math.random(-50, 50) triVert3X = math.random(-50, 50) triVert3Y = math.random(-50, 50) triVerts = {triVert1X, triVert1Y, triVert2X, triVert2Y, trivert3X, triVert3Y} triDense = (triVert1X + triVert2X + triVert3X) / 300 local tri = display.newPolygon(event.x, event.y, triVerts) tri:setFillColor(red, green, blue) physics.addBody(tri, {friction = fric, density = triDense, bounce = boing, shape = triVerts}) physics.setDrawMode("hybrid") end Runtime:addEventListener( "tap", onTap )