Please, help beginning LOVEr

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
klepikovmd
Prole
Posts: 3
Joined: Sun Sep 15, 2013 8:43 am
Location: Almaty

Please, help beginning LOVEr

Post by klepikovmd »

Hello everybody!
I am beginning LOVEr and now i am making my first game, a space shooter. When i am drawing a quad with rotation angle, center of rotation is bottom-left corner. How can i rotate around center of the quad?
User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

Re: Please, help beginning LOVEr

Post by mickeyjm »

Use the offset values of love.graphics.draw/love.graphics.drawq
eg:

Code: Select all

love.graphics.drawq(img,quad,x,y,rot,1,1,img:getWidth()/2,img:getHeight()/2)
The 1,1, bit is just the scale, I set it to 1 so there would be no difference (assuming you dont use it already in drawq).
The img:getWidth()/2 moves the rotated image by half the image width across, same with the height. This effectively rotates the image around the centre.
Your screen is very zoomed in...
klepikovmd
Prole
Posts: 3
Joined: Sun Sep 15, 2013 8:43 am
Location: Almaty

Re: Please, help beginning LOVEr

Post by klepikovmd »

Thank you very much!
It works!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests