按左右方向箭头设置整体透明度

"""
   按左右方向箭头设置整体透明度.py。
   本程序按左键透明度会增加,按右键透明度会减小。
   
"""
import pygame
from random import randint
from pygame.locals import *

width,height = 480,360

screen = pygame.display.set_mode((width,height))
pygame.display.set_caption("surface整体透明度测试程序")

# ultraman做为背景
ultraman = pygame.image.load('ultraman.png').convert()
superman = pygame.image.load("superman.jpg").convert()
width2 = superman.get_width()//2
height2 = superman.get_height()//2
# 把超人贴到屏幕中央坐标
center = width//2 - width2,height//2 -height2

alpha = 127
superman.set_alpha(alpha)    # 设置整体透明度

You must log in to read the rest of this article. Please log in or register as a user.