It looks like you're new here. If you want to get involved, click one of these buttons!
local landingGround = levelSelf.world:createBody({}) landingGround.name = "landingGround" local polygonShape = b2.PolygonShape.new() polygonShape:set(40.0, -163.0, 186.5, -95.0, 478.5, -82.0, 478.5, -202.0, 38.5, -163.5) landingGround:createFixture({shape = polygonShape, density = 0}) |
Comments
Just pass them in reverse order.
When I reverse the vertices:
polygonShape:set(38,-163, 478,-202, 478,-82, 186,-95, 40,-163)
I will get the same error.
Marc
Edit: If removing one of these vertices doesn't solve the problem, then pass them in reverse order.
need to modify some code to let it work.
Regards,
Marc
more vertices? I've got it work but not with the coordinates generated
by VertexHelper. I have to invert the Y values and rearrange the sequence
to get it work. Also which position values do you give a Polygonshape's
body?
Marc
all the coordinates for PolygonShape are relative, it means you can, for example, select one of the coordinate as 0, and provide other accordingly to the distance from this 0 coordinate. Then By setting position of the body that wears this PolygonShape, you can move it and position where you need it. It's similar using Shape object in Gideros.
Can you post some code or/and screenshot how it looks for you now?
create a shape on top of a part of the rock. I test on a 960x640px resolution.
When I open the picture in VertexHelper (I don't know if there is an other
to to do this) and draw the shape I will get the following coordinates:
38,-163,
478,-202,
477,-82,
186,-95
As I remember from Cocos2D and Box2D, that vertices will be specified from
the center of the picture. (0, 0) will be at (480, 320). To get it work in Gideros
you will need to invert the Y-coordinates and reorder it to meet the CCW rule:
478,202,
38,163,
186,95,
477,82
This is not really clear to me. Also how to position the shape. This is what I
did:
I think that the use of Physics is still quiet complicated to a lot of people. The
manuals are still not ready on this point. Is it an idea (I wan't to help if possible)
to create a graphical example of a screen and show what a world, body, fixture,
shape, etc. is. This could make it very clear.
Regards,
Marc