|  | 
 
| 
为什么temp.blit(target, (-x, -y)) 里面用(-x, -y)表示背景坐标而不是(x, y)?
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  
 
 复制代码...
def blit_alpha(target, source, location, opacity):
    x = location[0]
    y = location[1]
    temp = pygame.Surface((source.get_width(),source.get_height())).convert()
    temp.blit(target, (-x, -y))
    temp.blit(source, (0, 0))
    temp.set_alpha(opacity)
    target.blit(temp, location)
...
    blit_alpha(screen, turtle, position, 200)
...
 
 
你是巨猪怪_ 发表于 2020-4-8 10:13大神,我还不是很明白  能再讲仔细一点吗
这么给你说吧,你代码里面的x, y是是乌龟图像位置的左上角坐标对不对 
他是相对背景图的左上角坐标(0, 0) 来说的 
然后(-x, -y) 这里是相对于乌龟图像左上角坐标来看,刚好位于背景图左边的(0, 0) 点,这样要覆盖上去的图片就不会和原背景产生错位了 | 
 |