简体   繁体   English

Pygame 类型错误:参数 1 必须 > pygame.Surface,而不是 pygame.Rect

[英]Pygame TypeError: argument 1 must be > pygame.Surface, not pygame.Rect

I am making a helpscreen for my pygame and I keep getting this error message whenever I run it:我正在为我的 pygame 制作一个帮助屏幕,但每次运行它时我都会收到此错误消息:

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

I don't know how to fix it and I am still learning pygame so I need a pretty basic answer if possible.我不知道如何修复它,我仍在学习 pygame 所以如果可能的话我需要一个非常基本的答案。 My code is below:我的代码如下:

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()

Either just fill the display surface self.surface.fill(white) or create a background surface and blit it on the self.surface :要么只填充显示表面self.surface.fill(white)要么创建一个背景表面并将其 blit 到self.surface

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:参数1必须是pygame.Surface,而不是pygame.Rect - TypeError: argument 1 must be pygame.Surface, not pygame.Rect python-参数1必须是pygame.Surface,而不是pygame.Rect - python- argument 1 must be pygame.Surface, not pygame.Rect 该错误是什么意思:TypeError:参数1必须是pygame.Surface,而不是pygame.Rect - What does this error mean: TypeError: argument 1 must be pygame.Surface, not pygame.Rect 类型错误:在我的 Python 游戏中,参数 1 必须是 pygame.Surface,而不是 pygame.Rect - TypeError: argument 1 must be pygame.Surface, not pygame.Rect in my Python Game “参数 1 必须是 pygame.Surface,而不是 pygame.Rect”我该如何解决这个问题,它在说什么? - "argument 1 must be pygame.Surface, not pygame.Rect" How do I fix this, what is it saying? TypeError:参数1必须是pygame.Surface,而不是str - TypeError: argument 1 must be pygame.Surface, not str TypeError:参数1必须是pygame.Surface,而不是方法 - TypeError: argument 1 must be pygame.Surface, not method 类型错误:参数 1 必须是 pygame.Surface,而不是类型 - TypeError: argument 1 must be pygame.Surface, not type TypeError:参数1必须是pygame.Surface,而不是str [使用按钮的Pygame] - TypeError: argument 1 must be pygame.Surface, not str [Pygame using buttons] Pygame 错误“类型错误:参数 1 必须是 pygame.Surface,而不是列表” - Pygame error 'TypeError: argument 1 must be pygame.Surface, not list'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM