如何在 pygame 上绘制字符以显示在屏幕上

How to draw a charcter to screen on pygame

如何在 pygame 中将 ascii 字符绘制到屏幕上? 我所能找到的只是如何绘制一个矩形: pygame.draw.rect(screen, color, (x,y,width,height), thickness).

我想知道是否有办法在屏幕上绘制一个字符,例如 'A' 并显示在屏幕上。

谢谢。

我会这样做:

font = pygame.font.Font(<Font>, 36)
text = font.render("<Char>", 1, (10, 10, 10))
textpos = text.get_rect()
<Surface>.blit(text, textpos)

编辑:请注意 greater/less 符号之间的名称是占位符...