试图在屏幕上显示分数。我是通过清除屏幕上显示分数的部分,然后在中添加新的分数来完成的。然而,当我尝试这样做时,我不断得到这个错误“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()
我修正了如果有人想知道,没有足够的争论屏幕填充对于矩形部分
相关问题 更多 >
编程相关推荐