2 回答

TA貢獻1845條經(jīng)驗 獲得超8個贊
這是縮進的問題。在應用程序循環(huán)而不是事件循環(huán)中繪制場景:
# application loop
while True:
? ?
? ? # event loop
? ? for event in pygame.event.get():
? ? ? ? if event.type == pygame.QUIT:
? ? ? ? ?
? ? ? ? ? ? pygame.quit()
? ? ? ? ? ? sys.exit()
? ??
? ? #<--| INDENTATION
? ? screen.blit(bg_surface, (0, 0))
? ? screen.blit(bird_surface, (bird_rect))? ? ?
? ? floor_animation -= 1
? ? draw_floor()
? ? if floor_animation <= -275:
? ? ? ? floor_animation = 0? ? ? ? ? ??
? ? screen.blit(floor_surface, (floor_animation, 400))
? ? pygame.display.update()
注意,事件循環(huán)僅在事件發(fā)生時執(zhí)行,但應用程序循環(huán)是連續(xù)執(zhí)行的。

TA貢獻1829條經(jīng)驗 獲得超9個贊
我猜想在你的函數(shù)中,當鼠標懸停在圖像上或鼠標在時間 t1 的位置!= t2 的位置時,就會發(fā)生動作。還提供代碼,以便我們檢查可能出現(xiàn)的問題:)
添加回答
舉報