[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] fade out surfaces
On Fri, 2005-09-23 at 12:26 +1000, Luke Miller wrote:
> s.alpha -= 5 #or sometimes s.alpha += 5
> multiply_alpha(s.image, s.alpha)
> draw(s.image)
You are right about fading the alpha in. You'll need to keep a copy of
the original alpha and go back that each step you fade in. The integer
multiplication loses precision fast, so once you fade the alpha down, it
can't really come back up.
You are using the wrong type of arguments for multiple_alpha. It takes
an integer between 0 and 255. Think of this as multiplying between 0-1.
multiple_alpha(image, 128) will half the values in the per pixel alphas.
Passing 255 will have no effect, because it is like multiplying by 1.
Passing 0 will set all the alpha pixels to 0.