【发布时间】:2020-05-04 00:42:44
【问题描述】:
这是我用来尝试向屏幕添加文本的代码
font = pygame.font.Font('freesansbold.ttf', 20)
TextX = 700
TextY = 100
def showText(x,y):
text = font.render("random text", True, (255,0,0))
screen.blit(text, (x,y))
# Game Loop
running = True
while running:
showText(TextX,TextY)
I am trying to add the writing in the space on the right, in a column preferable 谁能告诉我为什么代码不允许我将文本blit到屏幕上,以及我应该如何更改代码以允许它将更多文本blit到屏幕上。
【问题讨论】:
-
看图片,我假设你有一个
pygame.display.update()。如果找不到,字体会引发错误,所以可能不是这样。确保在填满屏幕后对其进行 blitting。代码应该可以工作
标签: python text pygame pygame-surface