【问题标题】:Python Pygame score displayPython Pygame 分数显示
【发布时间】:2018-09-29 03:04:41
【问题描述】:

我正在尝试在 Pygame 的屏幕上显示分数。

这里是文本函数。执行时显示“**AttributeError: 'pygame.Surface' object has no attribute 'get'”* 感谢您的帮助!

   def text(self, surface, text, size, x, y):
          font= pg.font.Font(self.font_name, size)
          text_surface = font.render(text, True, WHITE )
          text_rect= text_surface.get.rect()
          text.rect.midtop = (x,y)
          self.screen.blit(text_surface, text_rect)

【问题讨论】:

    标签: python pygame display


    【解决方案1】:

    您的意思是text_surface.get_rect(),而不是text_surface.get.rect()

    另外,在你的函数中展望未来,你可能指的是text_rect而不是text.rect

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多