Arguments for 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
LagMasterSam
Prole
Posts: 8
Joined: Sun Aug 30, 2009 2:24 pm

Arguments for newPolygonShape()

Post by LagMasterSam »

I'm experimenting with LÖVE for the first time and I'm a little puzzled about this function. I see in the documentation that...

love.physics.newPolygonShape( body, ... )

Synopsis
polygon = love.physics.newPolygonShape( body, ... )

Arguments
body The Body to attatch the polygon to.
... The vertices of the PolygonShape.

Returns
PolygonShape The new PolygonShape.

I assumed the vertices are pairs of numbers as shown in the Box2D manual so I did this...

Code: Select all

function load()
	-- Code Here
	TriImage1 = love.graphics.newImage("BlueTri01.png")
	world = love.physics.newWorld(2000,2000)	
	TriBody1 = love.physics.newBody(world,1000,1000)
	TriShape1 = love.physics.newPolygonShape(TriBody1, {-1,0}, {1,0}, {0,2})
end
However, I get this error message...
main.lua:6 Incorrect number of arguments. Got[4], expected at least [7]
Stack traceback:
[C]: in function 'newPolygonShape'
main.lua:6 in function <main.lua:1>
Does that mean my polygons must have 6 vertices, or am I missing something here?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Arguments for newPolygonShape()

Post by bartbes »

You don't have to group the arguments in tables,

Code: Select all

function load()
	-- Code Here
	TriImage1 = love.graphics.newImage("BlueTri01.png")
	world = love.physics.newWorld(2000,2000)	
	TriBody1 = love.physics.newBody(world,1000,1000)
	TriShape1 = love.physics.newPolygonShape(TriBody1, -1,0, 1,0, 0,2)
end
should work.
LagMasterSam
Prole
Posts: 8
Joined: Sun Aug 30, 2009 2:24 pm

Re: Arguments for newPolygonShape()

Post by LagMasterSam »

Thanks. I'm just used to a vertex being represented by a data structure.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 43 guests