2016-07-26 287 views
1

我的代碼顯示記分牌總是閃爍,因爲我使背景變白。但我想要停下來。那麼是否有辦法讓pygame完成所有這些繪圖工作,並且在沒有顯示更新的情況下進行填充?當繪圖完成時,它會顯示新的結果,因此我不必看到每一步並因此閃爍?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

如果你有一個while循環,顯示你的窗口(我認爲你這樣做),那麼你很可能要求在循環要麼pygame.display.flip()pygame.display.update()。所以你不應該在你的分數函數中調用pygame.display.update()。刪除score函數中的pygame.display.update(),並在您的while循環中調用score函數。