[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Dumb little question: Crossfade



To fade from one image to another:

start = 255
end = 0

def draw():
"""Your draw func.

0 is fully transparent, 255 is fully opaque
screen = screen
surface_start, surface_end are your two image surfaces to fade.
"""

surface_start.set_alpha(start)
surface_end.set_alpha(end)
screen.blit(surface_start)
screen.blit(surface_end)
# note: you probably want to add a timer, ie: only increment
# every Xms instead of every frame, unless you have a fixed FPS.
if start > 0: start -= 1
if end < 255: end += 1
     



--
Jake