def __init__(self, text, fontSize, font, fontColour, xpos, ypos, background):
pygame.sprite.Sprite.__init__(self)
self.fontColour = pygame.Color(fontColour)
self.fontFace = pygame.font.match_font(font)
self.fontSize = fontSize
self.background = background
self.font = pygame.font.Font(self.fontFace, self.fontSize)
newSurface = self.font.render(text, True, self.fontColour)
self.rect = newSurface.get_rect()
if self.background != "clear":
self.image = pygame.Surface((self.rect.width, self.rect.height))
self.image.fill(pygame.Color(background))
self.image.blit(newSurface, [0, 0])
else:
self.image = newSurface
self.rect.topleft = [xpos, ypos]
评论列表
文章目录