模块'pygame.display'没有属性'fill'?

2024-09-30 03:25:32 发布

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

我正在尝试为我的pgame添加一个开始屏幕。 代码如下:

def game_intro():
    intro = True
    while intro:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                quit()

        pygame.display.fill(BLACK)
        largeText = pygame.font.Font('Arial',10)
        textSurf, textRect = text_objects("this is a game", largeText)
        textRect.centre = ((display_width/2), (display_height/2))
        pygame.display.blit(textSurf, textRect)
        pygame.display.update()
        clock.tick(15)
    pygame.display.update()
score = 000 
# Game loop
game_intro()

我得到的错误是:

^{pr2}$

以下是所有代码:https://www.dropbox.com/s/63u9yrfzagerwhz/game_test_jakob.zip?dl=0


Tags: 代码eventgametrue屏幕defdisplayupdate
1条回答
网友
1楼 · 发布于 2024-09-30 03:25:32

您正在尝试直接在“pygame.ds=isplay“模块-当它们应该在由pygame.display.set_mode初始化为显示的特殊表面对象上完成时

插入行

display = pygame.display.set_mode((800,600))

在函数的开头,将对pygame.display.fillpygame.display.blit的调用更改为仅display.fill和{}-但保持{}不变。在

相关问题 更多 >

    热门问题