Passing a table to newPolygonShape?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
conman420
Prole
Posts: 33
Joined: Sun Aug 31, 2008 8:46 pm

Passing a table to newPolygonShape?

Post by conman420 »

I have some code that generates co-ordinates to be passed to the polygon shape function, the code generates a table of coordinates of the map (I can't save the coordinates of the map to create the body that would just be stupid) the thing is the polygon shape doesn't accept a table and to my knowledge there is no way of converting a table into a series of arguments.

Can anyone shed any light on this?

nevermind IRC saves the day :)

There should still be an option for it to accept a table.
User avatar
Almost
Prole
Posts: 42
Joined: Fri Aug 21, 2009 8:04 pm
Location: Canada
Contact:

Re: Passing a table to newPolygonShape?

Post by Almost »

(In love 0.5,) This works for me:

points = {x1,y1,x2,y2,x3,y2}
love.graphics.polygon(type,points)

note that points is a one dimensional array.

EDIT: just realized I misread and you're talking about polygonshapes, not drawing a polygon. Still, I'm pretty sure that what I said is relevant to polygonshapes as well.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Passing a table to newPolygonShape?

Post by bartbes »

For anyone wanting to know the answer:

Code: Select all

t = {1, 2, 3, "a", "b", "c"}
unpack(t) --> 1, 2, 3, "a", "b", "c"
Post Reply

Who is online

Users browsing this forum: No registered users and 133 guests