Page 1 of 2
Drawing sprites with alpha?
Posted: Tue May 12, 2009 6:38 pm
by samivRMD
Is there a built in way to draw a sprite with alpha (so I can fade them in/out)? You can draw text with alpha, but that has some other issues like not being able to handle the pivot freely etc.
SamiV.
Re: Drawing sprites with alpha?
Posted: Wed May 13, 2009 5:29 am
by bartbes
You can use setColor in combination with love.color_modulate. (which is an argument to setColorMode)
Re: Drawing sprites with alpha?
Posted: Wed May 13, 2009 6:55 pm
by samivRMD
Ahh, thanks! I tried just setColor, didn't think that I need to set the blend mode as well (and I made a hack that abuses the font system...
SamiV.
Re: Drawing sprites with alpha?
Posted: Wed May 20, 2009 1:08 pm
by rude
The love.color_modulate setting should totally be the default color mode. (Already added to tracker).
Re: Drawing sprites with alpha?
Posted: Mon Jun 29, 2009 6:54 am
by Jasoco
We should be able to set image alpha ourselves without having to use the color part. I can't figure out how to set the color with alpha without setting the color. I don't want to set the color. Just the opacity. Opacity should be a parameter of the drawing commands.
Re: Drawing sprites with alpha?
Posted: Mon Jun 29, 2009 1:13 pm
by Robin
Jasoco wrote:We should be able to set image alpha ourselves without having to use the color part. I can't figure out how to set the color with alpha without setting the color. I don't want to set the color. Just the opacity. Opacity should be a parameter of the drawing commands.
Just the opacity? As in
Code: Select all
local c = love.graphics.getColor()
c:setAlpha(A)
love.graphics.setColor(c)
?
Re: Drawing sprites with alpha?
Posted: Mon Jun 29, 2009 9:07 pm
by Jasoco
Yeah, that works.. Kind of. A bit unwieldy though. I have to make sure to set the alpha back to full after doing the transparent images or else it draws other stuff transparent. It just seems silly to set the alpha to one thing then have to set it right back so everything else doesn't take on the opacity as well. Especially when we want to fade things in or out and have to constantly be changing the color:setAlpha every frame.
It would be much easier if opacity was just another parameter when calling draw functions. Angle, Scale, Opacity. You know?
Re: Drawing sprites with alpha?
Posted: Mon Jun 29, 2009 9:33 pm
by osgeld
yea until you dont need it, which is often
Re: Drawing sprites with alpha?
Posted: Mon Jun 29, 2009 9:34 pm
by Robin
I'm not sure, but maybe
Code: Select all
love.graphics.getColor():setAlpha(A)
works as well? That would at least be slightly closer to the simplicity of an argument to a function.
Re: Drawing sprites with alpha?
Posted: Mon Jun 29, 2009 11:45 pm
by Jasoco
I can't figure out how to make images transparent. For some reason it seems to only be affecting text.
I'm sorry but this is implemented very strangely. The opacity value should be part of the draw function like angle and scale are. The color stuff only seems to affect text. Which is fine, if I want to make text transparent. But how do I make an image draw opaque?