Drawing sprites with alpha?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
samivRMD
Prole
Posts: 3
Joined: Sat Apr 18, 2009 6:04 pm

Drawing sprites with alpha?

Post 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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Drawing sprites with alpha?

Post by bartbes »

You can use setColor in combination with love.color_modulate. (which is an argument to setColorMode)
samivRMD
Prole
Posts: 3
Joined: Sat Apr 18, 2009 6:04 pm

Re: Drawing sprites with alpha?

Post 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.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Drawing sprites with alpha?

Post by rude »

The love.color_modulate setting should totally be the default color mode. (Already added to tracker).
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Drawing sprites with alpha?

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Drawing sprites with alpha?

Post 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)
?
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Drawing sprites with alpha?

Post 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?
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: Drawing sprites with alpha?

Post by osgeld »

yea until you dont need it, which is often
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Drawing sprites with alpha?

Post 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.
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Drawing sprites with alpha?

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests