Closed codinghands closed 10 years ago
You can always flatten the table and then unpack it into addPolygon.
local pts = {{1, 2}, {3, 4}, ...}
local pts_ = {}
for i,v in ipairs(pts) do
table.insert(pts_, v[1])
table.insert(pts_, v[2])
end
local shape = HC:addPolygon(unpack(pts_))
I completely forgot about
unpack
Thanks!
Yes, unpack()
is the way to go. However, 100 vertices sounds like an awful lot for a collision shape and will probably slow down the detection. Do you really need all of those points or can the shape be simplified?
It's to represent an arc, like http://imgur.com/6GygUrl. I've tried to simplify it as much as possible (in game it's represented by a LOVE 'Mesh', with a Polygon shape used for collision detection, and this seemed to me to be the best way. Though if you have any thoughts on other methods I'd be very interested to hear them :)
Is it possible to modify HC so that addPolygon takes a table of points, rather than a long list of numbers? I'm trying to create a polygon with > 100 points and the values are contained within a table.