Rotate image

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
AlexsSteel
Prole
Posts: 17
Joined: Sat Dec 27, 2014 2:11 am

Rotate image

Post 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.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Rotate image

Post 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.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
AlexsSteel
Prole
Posts: 17
Joined: Sat Dec 27, 2014 2:11 am

Re: Rotate image

Post by AlexsSteel »

Thanks, it works!
Post Reply

Who is online

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