我正在尝试在 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)
最佳答案
您的意思是 text_surface.get_rect()
,而不是 text_surface.get.rect()
。
此外,展望您的函数,您可能指的是 text_rect
而不是 text.rect
。
关于Python Pygame得分显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49907034/