Page 1 of 1

My first experiments with mouse detection and image rotation

Posted: Fri Feb 01, 2013 8:29 pm
by dementia_patient567
I think I've been doing decent here, but there's obviously something wrong. I wanted to make the rotation centered at the middle of the picture, not the ship.x point. However it doesn't seem like using the (ship.x+imgs.ship:getWidth())/2 is getting me that...

Any help guys?

game.love
(1.81 KiB) Downloaded 272 times

Re: My first experiments with mouse detection and image rota

Posted: Fri Feb 01, 2013 8:35 pm
by Nixola
Check out the offset arguments of love.graphics.draw

Re: My first experiments with mouse detection and image rota

Posted: Fri Feb 01, 2013 8:36 pm
by dementia_patient567
That's what I was thinking about...What exactly ARE the offsets? I noticed them in other people's sources but I don't really know what they are.

Re: My first experiments with mouse detection and image rota

Posted: Fri Feb 01, 2013 8:38 pm
by Nixola
They move the ship image left and up by their amount, and the ship image rotation center by their amount right and down. Example, to rotate an image around its center:

Code: Select all

love.graphics.draw(ship.image, ship.x, ship.y, ship.rotation, 1, 1, ship.image:getWidth()/2, ship.image:getHeight()/2)

Re: My first experiments with mouse detection and image rota

Posted: Fri Feb 01, 2013 8:43 pm
by dementia_patient567
Awesome! I've been wanting this. Thank you!