字体显示时的Pygame问题

2024-04-16 21:20:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个问题,当我试图显示我的字体(当英雄死了),但没有显示。请帮我找出问题的根源

if hero.life == 0 or hero.life < 0:
    hero.image =  pygame.image.load("images/grave2.png").convert_alpha()
    text_end = font_end.render("GAME OVER",1,(255,255,255))
    fenetre.blit(fond_jeu, (0,0))
    fenetre.blit(text_end, (30, 30))
    hero.alive = 0

Tags: ortextimageif字体loadpygameend
1条回答
网友
1楼 · 发布于 2024-04-16 21:20:38

字体在哪里结束实例化?像这样的事情

texte = "Mon texte à afficher"
font_end = pygame.font.SysFont("freesansbold",22,bold=False,italic=False)
text = font_end.render(texte, True)

对于blit:

mySurface.blit(text,(x, y))
pygame.display.update()

相关问题 更多 >