2017-10-12 18 views

答えて

0

あなたが求めていることを正しく理解していれば、それは非常に簡単にtime.sleep(n)を使って実現できます。以下のように

import time 

while keepGoing: 
for event in pygame.event.get(): 
if event.type==pygame.QUIT: 
    keepGoing=False 
    if event.type==pygame.KEYDOWN: 
    if event.key==pygame.K_SPACE: 
     choice_f() 
     #Pause for 5 seconds Example. 
     time.sleep(5) 
     draw_f() 
    pygame.display.update() 
pygame.quit() 
+0

注: 'pygame.time.delayは()'あります。遅延がより正確になります。 –

+0

私はそれをしました。このコードを作成すると、関数choice_f()が一時停止後に実行されます。私はなぜ機能の順序が無視されるのか理解できません。 私が正しく理解していれば。まず、関数choice_f()を実行してから、time.sleep(5)、次にdraw_f()を実行する必要があります。しかし、私はまずtime.sleep(5)を実行してからchoice_f()とdraw_f()を実行します。なぜ私は知らないのですか? –

0
#Everything is working. I did it. 

import time 
while keepGoing: 
    for event in pygame.event.get(): 
     if event.type==pygame.QUIT: 
      keepGoing=False 
     if event.type==pygame.KEYDOWN: 
     if event.key==pygame.K_SPACE: 
      choice_f() 
      pygame.display.flip() 
      pygame.time.delay(1000)) 
      draw_f() 
    pygame.display.update() 
pygame.quit() 
関連する問題