显示surf.fill(白色)

2024-10-02 20:34:36 发布

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

当我运行此代码时:

def showStartScreen(self):
    titleFont = pygame.font.Font("freesansbold.ttf", 100)
    titleSurf1 = titleFont.render("Pong!", True, WHITE, LIGHT_BLUE)
    titleSurf2 = titleFont.render("Pong!", True, LAVENDER)

    degrees1 = 0
    degrees2 = 0
    while True:
        DISPLAYSURF.fill(WHITE)
        rotatedSurf1 = pygame.transform.rotate(titleSurf1, degrees1)
        rotatedRect1 = rotatedSurf1.get_rect()
        rotatedRect1.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)
        DISPLAYSURF.blit(rotatedSurf1, rotatedRect1)

        rotatedSurf2 = pygame.transform.rotate(titleSurf2, degrees2)
        rotatedRect2 = rotatedSurf2.get_rect()
        rotatedRect2.center = (WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)
        DISPLAYSURF.blit(rotatedSurf2, rotatedRect2)

我收到错误消息:

你知道吗显示surf.fill(白色) pygame.error错误:显示曲面退出


Tags: truerenderwindowpygamewhitepongdisplaysurftitlefont