HardonCollider polygon:unpack() question
Posted: Tue Apr 09, 2013 6:06 am
Hey. I'm using HardonCollider to glom together some almost-squares to form pentominoes. I'm using Polygon.mergeWith() with slightly perturbed coordinates to make this work. (So each square in the pentomino has non-co-linear edges with its neighbors.) So when I use Polygon.unpack() I get something like:
60.01 20.01 60 40.01 40 40 20 40.01 20.01 60.01 0.01 60 0 40 0.01 20 20.01 20.01 20 0.01 40 0 40.01 20
I would like to take the floor() of all of these pairs of numbers and turn them into another Polygon. That would make the example above into:
60 20 60 40 40 40 20 40 20 60 0 60 0 40 0 20 20 20 20 0 40 0 40 20
I'm confused how to do this, however. The type of the value returned from Polygon.unpack() is "number". What gives? I get an error if I try to iterate across that wit ipairs(). How do I turn this into an array of numbers that I can use to create a PolygonShape?
60.01 20.01 60 40.01 40 40 20 40.01 20.01 60.01 0.01 60 0 40 0.01 20 20.01 20.01 20 0.01 40 0 40.01 20
I would like to take the floor() of all of these pairs of numbers and turn them into another Polygon. That would make the example above into:
60 20 60 40 40 40 20 40 20 60 0 60 0 40 0 20 20 20 20 0 40 0 40 20
I'm confused how to do this, however. The type of the value returned from Polygon.unpack() is "number". What gives? I get an error if I try to iterate across that wit ipairs(). How do I turn this into an array of numbers that I can use to create a PolygonShape?