代码之家  ›  专栏  ›  技术社区  ›  BMango Gherkins

Button类给出一系列意外的错误消息[重复]

  •  -1
  • BMango Gherkins  · 技术社区  · 1 年前

    有没有一种方法可以使用python在pygame窗口上显示文本?

    我需要显示一堆更新的实时信息,而不是为我需要的每个角色制作图像。

    我可以将文本快速传送到屏幕上吗?

    0 回复  |  直到 2 年前
        1
  •  0
  •   Gabriel Araujo    3 年前

    对可以在pygame中绘制文本:

    # initialize font; must be called after 'pygame.init()' to avoid 'Font not Initialized' error
    myfont = pygame.font.SysFont("monospace", 15)
    
    # render text
    label = myfont.render("Some text!", 1, (255,255,0))
    screen.blit(label, (100, 100))