Rendering text with multiple lines in pygame

后端 未结 9 1592
日久生厌
日久生厌 2020-11-29 12:15

I am trying to make a game and I am trying to render a lot of text. When the text renders, the rest of the text goes off the screen. Is there any easy way to make the text g

9条回答
  •  爱一瞬间的悲伤
    2020-11-29 12:49

    There is no easy way to render text on multiple lines in pygame, but this helper function could provide some use to you. Just pass in your text (with newlines), x, y, and font size.

    def render_multi_line(text, x, y, fsize)
            lines = text.splitlines()
            for i, l in enumerate(lines):
                screen.blit(sys_font.render(l, 0, hecolor), (x, y + fsize*i))
    

提交回复
热议问题