Python 两个表面不是闪电游戏

Python 两个表面不是闪电游戏,python,pygame,pygame-surface,Python,Pygame,Pygame Surface,我试图在我的Pygame屏幕上呈现一些字体,但它从未显示。我认为我的一切都设置正确,我的程序没有抛出任何错误,所以我不确定是什么错了。这是我用来尝试创建文本的代码: pygame.init() pygame.display.set_caption("MyGame") font = SysFont("Times", 24) #Create a new font using times if it exists, else use system font. white = (255, 255, 25

我试图在我的Pygame屏幕上呈现一些字体,但它从未显示。我认为我的一切都设置正确,我的程序没有抛出任何错误,所以我不确定是什么错了。这是我用来尝试创建文本的代码:

pygame.init()
pygame.display.set_caption("MyGame")
font = SysFont("Times", 24) #Create a new font using times if it exists, else use system font.
white = (255, 255, 255)

while True:  #Game loop
  label = font.render("Score: " + str(score), 1, white)
  self.surface.blit(label, (100, 100))
  # Do other game things....
  self.board.draw()
  pygame.display.update()
  self.clock.tick(60)
在我的init函数中:

def __init__(self):
    self.surface = pygame.display.set_mode((400, 500)) #Set dimensions of game window. Creates a Surface
    self.clock = pygame.time.Clock()
    self.board = Board(self.surface)  # Board is an object in my game
我做错了什么?我已经查阅了所有Pygame文档,但是我看不到我的代码中有任何错误。我还尝试使用

font = pygame.font.Font("/System/Library/Fonts/Helvetica.dfont", 24)

但似乎什么都不管用

正如furas所建议的,问题是由我在绘图后填充表面造成的。

使用
print()
查看执行了代码的哪一部分。也许你们用颜色填充表面,这样你们就可以删除文本了。也许你应该在画板后再画文字?啊!渲染后我填充了整个屏幕。非常感谢你!