local triange = display.newPolygon(200,200,{100,100,100,0,0,0})
physics.addBody(triange,“static”,{shape = {100,100,100,0,0,0}})
local triange = display.newPolygon(200,200,{100,100,100,0,0,0})
physics.addBody(triange,“static”,{shape = {100,100,100,0,0,0}})
One is in pixel space, one is in object space (the physics body) which is centered about 0.
I think the latter should be something like:
physics.addBody(triange,"static",{shape = { -50,-50, 50,-50, 50, 50} })
Updated above, so double check if you just grabbed it.
It’s a shame I can’t use the same shape
It it what it is. The body shape is an artifact of using Box 2D. Also, it makes more sense that way, whereas the pixel dimensions of a polygon must be freeform.
Also, with some effort you could make a builder function to handle creating the body from the polygon shape information.
Corona SDK
One is in pixel space, one is in object space (the physics body) which is centered about 0.
I think the latter should be something like:
physics.addBody(triange,"static",{shape = { -50,-50, 50,-50, 50, 50} })
Updated above, so double check if you just grabbed it.
It’s a shame I can’t use the same shape
It it what it is. The body shape is an artifact of using Box 2D. Also, it makes more sense that way, whereas the pixel dimensions of a polygon must be freeform.
Also, with some effort you could make a builder function to handle creating the body from the polygon shape information.
Corona SDK