Page 1 of 1

love.physics.newPolygonShape troubles

Posted: Wed Jun 09, 2010 5:50 am
by smartazz
I'm trying to draw a polygon with arbitrary coordinate values but it won't show up and isn't detected when the player goes past it (no collision). The coordinate values are:

Code: Select all

923, 475, 923, 411, 1157, 411, 1157, 475
They're stored in a table called collCoordsTable.

I've placed a body for it in a position such that it basically falls in the middle of the four sets of coordinates. Then I do:

Code: Select all

collision_test1 = {}
collision_test1.body = love.physics.newBody(world, _body_x, _body_y)
collision_test1.shape = love.physics.newPolygonShape(collision_test1.body, unpack(collCoordsTable))
collision_test1.shape:setData("collision_test1")
I draw a line for the boundary box but nothing is draw:

Code: Select all

love.graphics.polygon('line', collision_test1.shape:getBoundingBox())
The player shape and all other various shapes show just fine, their boundary boxes show and their bodies are collidable, just not this polygon. Any ideas why? If you need more info let me know.

Re: love.physics.newPolygonShape troubles

Posted: Fri Jun 11, 2010 8:55 am
by smartazz
Nevermind, found the problem. Changing

Code: Select all

collision.body = love.physics.newBody(world, _body_x, _body_y)
to

Code: Select all

collision.body = love.physics.newBody(world)
works fine now.