我这里有一些简单的代码,表现不像我预期的那样:
import pygame,sys
from pygame.locals import *
pygame.init()
window = pygame.display.set_mode((1300,700))
while True:
window.fill((0,0,0))
pygame.display.update()
#show black window, should happen before wait
pygame.time.wait(2000)
#program waits for 2 seconds, and then shows black window
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit(0)
程序在更新显示并显示黑色窗口之前等待2秒钟。为什么?由于python是一种解释型语言,pygame.display.update()
之前不应该发生pygame.time.wait(2000)
?