love.physics.newPolygonShape troubles

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
smartazz
Prole
Posts: 13
Joined: Mon Jan 11, 2010 10:04 am
Contact:

love.physics.newPolygonShape troubles

Post 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.
User avatar
smartazz
Prole
Posts: 13
Joined: Mon Jan 11, 2010 10:04 am
Contact:

Re: love.physics.newPolygonShape troubles

Post 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.
Post Reply

Who is online

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