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

Re: [pygame] Cycling images



On 4 Mar 2004 at 15:56, lorca wrote:

> mmmm, I've problem with this, the alpha channel is not working, this
> function allways prints "NO alpha" although the image has the alpha
> channel (and it doent shows the transparency bg, it shows in black)

>         i = pygame.Surface(size)

There is no alpha because you are creating a surface with no alpha.  You could create the 
surface with pixel alpha, but that would defeat the purpose because than it would always 
have pixel alphas.

What you want to do is check the source img, and then conditionally create your new 
surface with or without an alpha channel.  Do the creation in one step:

if img.get_alpha:
   i = Surface(size).convert_alpha()
else:
   i = Surface(size).convert()

i.blit(yada yada)

Regards,
Steve