Page 1 of 1

Rotate image

Posted: Thu Feb 19, 2015 8:27 pm
by AlexsSteel
Hi,

I am working on a tile-based map, but when i try to rotate a square image (90, 180 and 270 degrees), it is rotated by the top-left corner, how can i use his center to rotate it?

* I'm sorry about my english.

Re: Rotate image

Posted: Thu Feb 19, 2015 8:31 pm
by davisdude
Use the offset x and y parameters of love.draw and offset it by half of the width and height of the image. So if your image was 32 x 64 you would do

Code: Select all

love.graphics.draw( image, x, y, rotation, 1 [scale x], 1 [scale y], 16 [offset x], 32 [offset y] )
See here for more.

Edit:
By the way, you should not use the ['s. Those are there to describe what each number does.

Re: Rotate image

Posted: Thu Feb 19, 2015 8:56 pm
by AlexsSteel
Thanks, it works!