为什么我会遇到这个问题,我该如何解决?

时间:2018-01-05 20:01:22

标签: python pygame window blit

我正在为我的pygame制作一个帮助屏幕,每当我运行它时我都会收到此错误消息:

> self.surface.blit(self.helpscreen) TypeError: argument 1 must be
> pygame.Surface, not pygame.Rect

我不知道如何修复它,我还在学习pygame所以如果可能的话我需要一个非常基本的答案。我的代码如下:

def help(self):

    pygame.init()
    self.FPS = 60
    self.fps_clock = pygame.time.Clock()
    self.surface = pygame.display.set_mode((640, 480))
    helpscreen = DISPLAY_SURF.fill(white)
    self.surface.blit(helpscreen)
    # This class sets the basic attributes for the window.
    # The clock is set to 60 and the name of the window
    # is set to The Hunt which is a working title for my project
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
    while True:
        pygame.display.update()
        self.fps_clock.tick(self.FPS)
        self.process_game()

1 个答案:

答案 0 :(得分:1)

只需填充显示表面self.surface.fill(white)或创建背景表面并在self.surface上单击它:

helpscreen = pygame.Surface(self.surface.get_size())
helpscreen.fill(white)
self.surface.blit(helpscreen, (0, 0))