Page 1 of 1

Corners from body?

Posted: Fri Dec 17, 2010 2:25 am
by Socks
Making a shape with :getBoundingBox() is ok, but if it rotates, the bounding box does not. Is there any way to get the corners of a shape?

Re: Corners from body?

Posted: Fri Dec 17, 2010 2:41 am
by Ryne
Socks wrote:Making a shape with :getBoundingBox() is ok, but if it rotates, the bounding box does not. Is there any way to get the corners of a shape?
Kind of vague but your shape should have an X/Y value right? The starting X/Y of a shape is in the top left corner of the shape. So X/Y would be your top left corner.

For example.

Code: Select all

function love.load()
     box = {}
     box.x = 50
     box.y = 50
     box.w = 100
     box.h = 100
end

function love.draw()
     love.graphics.rectangle("fill", box.x, box.y, box.w, box.h)
end
In that example we draw a rectangle shape using a pre-set x/y/w/h. So we already know the boxes top left corner is x50, y50. Since the box has a width of 100 then its top right corner would be 150x, 50y. Get it?

I'm not sure if this is really what you were asking about, but I hope it helps. Maybe you can post some code, and ask a more specific question?