【发布时间】:2016-02-04 11:48:07
【问题描述】:
如何在 pygame 中将 ascii 字符绘制到屏幕上?
我所能找到的只是如何绘制一个矩形:
pygame.draw.rect(screen, color, (x,y,width,height), thickness).
我想知道是否有办法在屏幕上绘制一个字符,例如“A”并让它出现在屏幕上。
谢谢。
【问题讨论】:
如何在 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)
编辑:请注意,较大/较小符号之间的名称是占位符...
【讨论】: