2017-08-29 81 views
1

我想添加一個啓動畫面pygame的,但我不能得到它的工作,這裏是代碼:pygame的閃屏

def game_intro(): 
    intro = true 
    while intro: 
     for event in pygame.event.get(): 
      if event.type == pygame.QUIT: 
       pygame.quit() 
       quit() 

    gamedisplay.fill(WHITE) 
    largeText = pygame.font.Font('Arial',155) 
    textSurf, textRect = text_objects("test", largeText) 
    textRect.centre = ((display_width/2), (display_height/2)) 
    gamedisplay.blit(textSurf, textRect) 
    pygame.display.update() 
    clock.tick(15) 

,這裏是我得到的錯誤:

File "/Users/harrisonj11/NetBeansProjects/game_test_jakob/src/game_test_jakob.py", line 188, in <module> 
     game_intro() 
     File 

"/Users/harrisonj11/NetBeansProjects/game_test_jakob/src/game_test_jakob.py", line 172, in game_intro 
     intro = true 
    NameError: name 'true' is not defined 

回答

0

你可以試着更換:

intro = true 

intro = True 
+1

感謝,似乎工作,但它只是現在空白scren現在 –

+0

請問空白啓動畫面的另一個問題,並提供一個最小的代碼示例,我們可以運行,因此它更容易幫助你。 答案解決了您發佈的錯誤追蹤;如果你滿意,你可以考慮接受它。 –

+0

'gamedisplay.fill(WHITE)'很可能是你獲得白屏的原因;那麼你可能必須刷新它或交換緩衝區。 –