Jeremy1451
Jeremy1451

Reputation: 21

Python Pygame score display

I am trying to display a score on screen in Pygame.

Here is the text function. When executed, it displays "**AttributeError: 'pygame.Surface' object has no attribute 'get'"* Thanks for the help!

   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)

Upvotes: 2

Views: 242

Answers (1)

Triclops200
Triclops200

Reputation: 833

You meant text_surface.get_rect(), not text_surface.get.rect().

Also, looking ahead in your function, you probably meant text_rect instead of text.rect.

Upvotes: 4

Related Questions