Page 1 of 1

Image rotation

Posted: Sat Jan 07, 2012 9:49 pm
by Arthes
Hello.
How to rotate the image created by love.graphics.newImage()?
Very thanks for replies.

Re: Image rotation

Posted: Sat Jan 07, 2012 10:02 pm
by Jack
If you are only drawing one image...

Code: Select all

function love.draw()

love.graphics.rotate(angleInRadians) -- Rotates all items drawn.
love.graphics.draw(yourImage,x,y)  -- Draws your image.

end
To convert an angle to radian, you can use...

Code: Select all

radian = angle*math.pi/180
When you use this it rotates from 0,0 not your image's x,y so you have to compensate. Is that what you meant?

Re: Image rotation

Posted: Sat Jan 07, 2012 10:12 pm
by Jasoco
Well, if you have more than one image, you use the image's rotation parameter itself.

Code: Select all

love.graphics.draw(image, x, y, rotation_in_radians, scale_x, scale_y, offset_x, offset_y)