如何在pygam屏幕上绘制字符

2024-03-29 08:08:21 发布

您现在位置:Python中文网/ 问答频道 /正文

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

我想知道有没有办法在屏幕上画一个像“a”这样的字符,然后让它出现在屏幕上。

谢谢。


Tags: rect屏幕ascii绘制字符widthscreenpygame
1条回答
网友
1楼 · 发布于 2024-03-29 08:08:21

我会这样做的:

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

编辑:注意大/小符号之间的名称是占位符。。。在

相关问题 更多 >