我一直在四处搜寻,但我真的找不到任何关于如何编写文本的好资源?我试过使用文本渲染命令,但它对我不起作用。
还有,当你在这里的时候;是否有一种“覆盖”类型的东西,您可以在其中准确看到坐标的位置?每次我使用坐标来确定一个区域时,我真的无法弄清楚整个坐标系是如何工作的,除了反复试验之外……
非常感谢,
最佳答案
surf = pygame.display.set_mode((WIDTH, HEIGHT))
...
# get font object
font = pygame.font.SysFont('Arial', 12, bold=True)
# render a given font into an image
img = font.render('Text to write', True,
pygame.Color(FONT_FG_COLOR),
pygame.Color(FONT_BG_COLOR))
# and finally put it onto the surface.
# the code below centres text image
surf.blit(img, ((surf.get_width() - img.get_width())/2,
(surf.get_height() - img.get_height())/2))
关于python - pygame - 如何将文本写入特定位置?另外,如何使用坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20550743/