首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pygame :参数1必须是> pygame.Surface,而不是pygame.Rect

Pygame :参数1必须是> pygame.Surface,而不是pygame.Rect
EN

Stack Overflow用户
提问于 2018-01-05 20:01:22
回答 1查看 41关注 0票数 1

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

self.surface.blit(self.helpscreen) TypeError:参数1必须是> pygame.Surface,而不是pygame.Rect

我不知道如何解决它,我仍然在学习游戏,所以我需要一个相当基本的答案,如果可能的话。我的代码如下:

代码语言:javascript
复制
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()
EN

回答 1

Stack Overflow用户

发布于 2018-01-05 21:57:47

只需填充显示面self.surface.fill(white)或创建背景面并在self.surface上空白:

代码语言:javascript
复制
helpscreen = pygame.Surface(self.surface.get_size())
helpscreen.fill(white)
self.surface.blit(helpscreen, (0, 0))
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48120504

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档