gpt4 book ai didi

python - Pygame TypeError : argument 1 must be > pygame. Surface,而不是 pygame.Rect

转载 作者:太空宇宙 更新时间:2023-11-03 14:18:11 31 4
gpt4 key购买 nike

我正在为我的 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()

最佳答案

要么只填充显示表面self.surface.fill(white),要么创建一个背景表面并将其blit到self.surface:

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

关于python - Pygame TypeError : argument 1 must be > pygame. Surface,而不是 pygame.Rect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48120504/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com