Page 1 of 1
Rotation?
Posted: Wed Feb 26, 2014 12:44 am
by Findo777
The wiki did not give a straight answer, and I was somewhat confused.
Let say I made a image move along the screen if a key isDown, but I wanted it to rotate on turns
How would I rotate the image?
My guess;
love.graphics.setRotation()-- angle here?
If this is not correct, please correct it for me.
Thank you!
Re: Rotation?
Posted: Wed Feb 26, 2014 1:31 am
by davisdude
If you have a picture...
Code: Select all
love.graphics.draw( drawable, x, y, r, sx, sy, ox, oy, kx, ky )
With r being the rotation, in radians.
Otherwise, do this:
Code: Select all
function love.draw()
love.graphics.push()
love.graphics.rotate( r ) -- Being the same thing as before.
-- Draw stuff.
-- Note you don't have to indent, just personal preference.
love.graphics.pop()
end
Re: Rotation?
Posted: Wed Feb 26, 2014 2:24 am
by Findo777
What does this mean?
x, y, r, sx, sy, ox, oy, kx, ky )
I know what the r is, but what does the rest mean?
Also, do you need the code above to have all of those letters or can it be anything of your choice?
Re: Rotation?
Posted: Wed Feb 26, 2014 2:43 am
by szensk
number x (default: 0)
The position to draw the object (x-axis).
number y (default: 0)
The position to draw the object (y-axis).
number r (default: 0)
Orientation (radians).
number sx (default: 1)
Scale factor (x-axis).
number sy (default: sx)
Scale factor (y-axis).
number ox (default: 0)
Origin offset (x-axis).
number oy (default: 0)
Origin offset (y-axis).
number kx (default: 0)
Shearing factor (x-axis).
number ky (default: 0)
Shearing factor (y-axis).
from
https://www.love2d.org/wiki/love.graphics.draw
Re: Rotation?
Posted: Wed Feb 26, 2014 3:30 pm
by Jeeper
Findo777 wrote:What does this mean?
x, y, r, sx, sy, ox, oy, kx, ky )
I know what the r is, but what does the rest mean?
Also, do you need the code above to have all of those letters or can it be anything of your choice?
If you only need X and Y then you dont need to type the rest. But if you need ox then you cant skip anything that is BEFORE ox, but you can still skip everything that is AFTER. You obviously replace the letters with the approprate thing.
So you dont type (x,y,r) but rather (200, 132, math.pi / 2)