0
我一直在使用pygame來創建一個非常基礎的遊戲,只是爲了試驗,而我最近遇到了一些滯後。每當我添加此代碼:鼠標位置更新時滯後?
if exitcode==0:
pygame.font.init()
font = pygame.font.Font(None, 24)
text = font.render("Accuracy: "+str(accuracy)+"%", True, (255,0,0))
textRect = text.get_rect()
textRect.centerx = screen.get_rect().centerx
textRect.centery = screen.get_rect().centery+24
screen.blit(gameover, (0,0))
screen.blit(text, textRect)
else:
pygame.font.init()
font = pygame.font.Font(None, 24)
text = font.render("Accuracy: "+str(accuracy)+"%", True, (0,255,0))
textRect = text.get_rect()
textRect.centerx = screen.get_rect().centerx
textRect.centery = screen.get_rect().centery+24
screen.blit(youwin, (0,0))
screen.blit(text, textRect)
它滯後。我認爲這可能是因爲我的while
循環,但事實並非如此。任何人都可以告訴我我的滯後來源嗎?如果需要,我可以從我的遊戲中發佈其他代碼。謝謝!