Corners from body?

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
Socks
Prole
Posts: 14
Joined: Sat Dec 04, 2010 2:12 am

Corners from body?

Post 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?
:p
User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Re: Corners from body?

Post 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?
@rynesaur
Post Reply

Who is online

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