Pygame BLEND全屏Bug

2024-05-28 23:51:08 发布

您现在位置:Python中文网/ 问答频道 /正文

好吧,所以我一直在使用一个特殊的_flags BLEND_MULT surface来为我在pygame中制作的一个小游戏添加一些灯光。在

当程序被窗口化时,它工作得很好。然而,每当我试图使窗口全屏显示时,混合曲面并不是与其他组件一起全屏显示的,它只是从屏幕边缘延伸出去。因此,blitted到过渡曲面的任何渐变也处于错误的位置。在

This image shows the error when I have the Window Full screened

我知道这是特殊的_标志(而不是我错误地blitting表面)的问题,因为当我删除特殊的_flags参数时,表面会用其余的组件完美地填充屏幕

This image shows the window correctly Full screening

基本上,我要求一种方法来修复这个错误,这样我就可以保留特殊的_flags参数而不会在全屏显示。这样我就不必完全重做照明了。在

下面是将表面(雾面)绘制到游戏显示的代码

def render_fog(self):
    #draw light onto fog
    for fog in self.all_fog:
        fog.image.fill(fog.colour)
        self.light_rect.centerx = self.player.rect.centerx - fog.x
        self.light_rect.centery = self.player.rect.centery - fog.y
        fog.image.blit(self.light_mask, self.light_rect)
        for light in self.all_light:
            light.centerx = light.x 
            light.centery = light.y
            fog.image.blit(light.image, (light.rect))
        self.gameDisplay.blit(fog.image, (fog.x, fog.y), special_flags = pygame.BLEND_MULT)

下面是一个例子,在全屏显示同样的错误,只需按f键即可

^{pr2}$

Tags: therectimageself错误表面flagslight

热门问题