显示记分板的代码总是闪烁,因为我将背景设为白色。但我想要停下来。那么有没有办法让pygame完成所有这些绘图和填充而不更新显示,当绘图完成时它会显示新结果,所以我不必看到每一步,从而闪烁?
def score():
while ScoreTrue:
pygame.event.get()
window.fill(white)
display_score= (display_height/ 1.2)
message_display("Scoreboard", 2, 5)
message_meduim("5th place: " + ", ".join( repr(e) for e in Scoreboard[0] ), 3, display_score)
message_meduim("4th place:" + ", ".join( repr(e) for e in Scoreboard[1]), 3, display_score - 100)
message_meduim("3rd place:" + ", ".join( repr(e) for e in Scoreboard[2]), 3, display_score - 200)
message_meduim("2nd place:" + ", ".join( repr(e) for e in Scoreboard[3]), 3, display_score - 300)
message_meduim("1st place:" + ", ".join( repr(e) for e in Scoreboard[4]), 3, display_score - 400)
Button("Play again", display_width/1.2,display_height/1.6, display_width/8, display_height/9, red, red_light, "play")
答案 0 :(得分:0)
如果你有一个显示你的窗口的while循环(我假设你这样做),那么你可能在循环中调用pygame.display.flip()
或pygame.display.update()
。因此,您也不必在分数功能中调用pygame.display.update()
。移除pygame.display.update()
函数中的score
,然后在while循环中调用score
函数。