Hello,
I have a really quick question in regards to Quads. Is it possible to mirror an image, that the quad is referencing (a sprite sheet, for instance), on the fly?
Say, for instance, when you are pressing "right" it uses the reference image, but when you press "left" it mirrors the reference image.
I've looked around on the boards, but didn't come across anything that seemed 100% appropriate. I apologize in advance if this is a common topic, but it didn't appear to be mentioned.
I suspect that when drawing the image you can use the additional variables(rotation, scale, etc) to alter the orientation, but I'm not at a computer that I can test this on and it's been killing me to try and figure out.
Thanks!
Mirroring Sprites (Using Quads)
- pakoskyfrog
- Citizen
- Posts: 62
- Joined: Mon Feb 04, 2013 12:54 pm
- Location: France
Re: Mirroring Sprites (Using Quads)
http://www.love2d.org/wiki/love.graphics.drawq
If you look at this, you can see there are the scales factors, and if you put -1 in one of them, you get a flip !
If you look at this, you can see there are the scales factors, and if you put -1 in one of them, you get a flip !
-
- Prole
- Posts: 11
- Joined: Thu Feb 21, 2013 3:03 am
Re: Mirroring Sprites (Using Quads)
Great, thank you for a quick response!
If I'm mirroring the original image, does this require me to also put in a number for the offset? I'm trying to think about how this would look inside the draw function.
I suppose it could look something like this:
Then based on the direction, I could change the variable accordingly? I'm somewhat new to this, so you have my apologies it this is a very novice question.
Thank you!
If I'm mirroring the original image, does this require me to also put in a number for the offset? I'm trying to think about how this would look inside the draw function.
I suppose it could look something like this:
Code: Select all
function love.draw()
love.graphics.drawq(img, quad[direction][iterator], char.x, char.y, 0, char.scale, 1, char.width)
end
Thank you!
-
- Citizen
- Posts: 65
- Joined: Sat Dec 22, 2012 8:17 am
Re: Mirroring Sprites (Using Quads)
You need an offset, but I think it's easier to offset the image so that its center is on the origin, like so:
Code: Select all
dir = 1 -- to mirror set to -1
img = ...
origin = {x = img:getWidth() * 0.5, y = img:getHeight() * 0.5}
love.graphics.draw(img, x, y, r, dir, 1, origin.x, origin.y)
-
- Prole
- Posts: 11
- Joined: Thu Feb 21, 2013 3:03 am
Re: Mirroring Sprites (Using Quads)
Awesome, thank you for the reply. I have it working properly at the moment, but now I'm having a strange issue with animation smoothness.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests