ValueError:无效的rectstyle对象Pygame

时间:2018-11-26 12:05:21

标签: python pygame game-development

试图在屏幕上显示分数。我通过清除显示分数的屏幕部分来完成此操作,然后添加新分数。但是,当我尝试执行此操作时,我一直收到此错误“ ValueError:invalid rectstyle object”。有人对如何解决这个问题有任何想法吗?

这里是所有涉及的代码:

内部主要功能:

 screen.fill(WHITE,((1280/2),(720/2) - 250))
 displayText(scoreText,50,((1280/2),(720/2) - 250))

正在使用的其他功能:

def textObjects(text,font):
    textSurface = font.render('{}'.format(text),True,BLACK)
    return textSurface, textSurface.get_rect()

def displayText(text,fontSize = 100, center = ((1280/2),(720/2))):
    fontInfo = pygame.font.Font(None,fontSize)
    textSurf, textSize = textObjects(text,fontInfo)
    textSize.center = (center)
    screen.blit(textSurf,textSize)
    pygame.display.update()

1 个答案:

答案 0 :(得分:0)

如果有人想知道的话,我将其修复,在screen.fill中没有足够的参数用于直肠部分

相关问题