Is there a simple way to rotate an image?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Is there a simple way to rotate an image?
Hi guys. I haven't used LÖVE in a while and I'm trying to get back into it. Right now I'm just testing out some of the basics again, but I can't seem to find a simple way to rotate an image (loaded using love.graphics.newImage). I looked at the Wiki and a few libraries and stuff, but things like love.physics or an entire animation library seem a little complicated for something like this. I messed around with love.graphics.drawq a bit, but can't seem to make it rotate around the center of the image (it rotates around the upper left it seems). Is there something obvious and easier that I'm missing here, or should I just use one of the above-mentioned methods?
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Is there a simple way to rotate an image?
Rotating is done from the top left, but you can offset the position AND rotation using the last two parameters.
love.graphics.draw
So, if you've got a 50 by 50 pixel image called img that you want drawn (from the center) at 200x200 at .5 radians (about 30 degrees), the code would look like this: The 1s are the scale parameters, in this example we are not scaling up or down.
love.graphics.draw
So, if you've got a 50 by 50 pixel image called img that you want drawn (from the center) at 200x200 at .5 radians (about 30 degrees), the code would look like this:
Code: Select all
love.graphics.draw(img, 200, 200, .5, 1, 1, 25, 25)
Kurosuke needs beta testers
Re: Is there a simple way to rotate an image?
Awesome, thanks. Not really sure how I missed this the first time around.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 0 guests