|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import pygame
import sys
from pygame.locals import *
pygame.init()
size = width,height = 500,375
bg = (0,0,0)
clock = pygame.time.Clock()
screen = pygame.display.set_mode(size,RESIZABLE)
pygame.display.set_caption("shiyan4")
turtle = pygame.image.load("feiji.png").convert_alpha()
background = pygame.image.load("cloud.jpg").convert()
position = turtle.get_rect()
position.center = width//2,height//2
print(position)
def blit_alpha(target,source,location,opacity):
x = location[0]
y = location[1]
temp = pygame.Surface((source.get_width(),source.get_height())).convert()
#把透明的screen
temp.blit(target,(-x,-y))
temp.blit(source,(0,0))
temp.set_alpha(opacity)
target.blit(temp,location)
while True:
for event in pygame.event.get():
if event.type == QUIT:
sys.exit()
screen.blit(background,(0,0))
blit_alpha(screen,turtle,position,200)
pygame.display.flip()
clock.tick(30)
[/code]
函数blit_alpha中的temp.blit(target,(-x,-y))的意思,或者(-x,-y)的意义。谢谢
|
|