how to use pygame set_alpha() on a picture

前端 未结 3 534
暖寄归人
暖寄归人 2020-12-06 13:38

I am using pygame and python for a project I am building, and I am building a splashscreen for when the game first opens. I have a .png that I want to show for the splashscr

3条回答
  •  萌比男神i
    2020-12-06 13:56

    PygameNerd your example is close, but it doesn't really work.

    The image.convert() will fade properly, but it doesn't support alpha channel. Try it on a non black background & it shows. The image.convert_alpha() will not fade, but the alpha channel does work properly.

    I'm surprised that pygame doesn't support this out of the box, but anyway. Here is an answer: http://www.nerdparadise.com/tech/python/pygame/blitopacity/

    Its a bit complex, but works fine. Transparent background & fading all in one package.

提交回复
热议问题