【发布时间】:2023-03-15 17:40:01
【问题描述】:
我正在 pygame 中进行一个项目,文本应该显示角色的语音。我已经显示了文本,但它跑出了屏幕。我尝试了一种文本换行的方法,但它没有移动到下一行,所以它只是重叠在同一行上。我不知道是否可以设置某种边界或边框或文本换行。我只能找到 python 的东西,而不是 pygame。
这就是我的文字内容
white = (255,255,255)
def text_objects(text, font):
textSurface = font.render(text, True, white)
return textSurface, textSurface.get_rect()
def words(text):
largeText = pygame.font.Font('freesansbold.ttf', 18)
TextSurf, TextRect = text_objects((text), largeText)
TextRect = ((13), (560))
screen.blit(TextSurf, TextRect)
` pygame.display.update()
words("This is just filler. Yup, filler to test if this will run off the screen. And apparently \n doesn't start a new line... Doo duh doo. Bum Dum pssst.")
【问题讨论】: