第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么 pygame 窗口動畫僅在我移動光標時才起作用

為什么 pygame 窗口動畫僅在我移動光標時才起作用

呼喚遠方 2023-08-22 16:56:26
屏幕僅在我移動光標時更新有人知道如何解決此問題import pygame, sysdef draw_floor():? ? screen.blit(floor_surface, (floor_animation, 400))? ? screen.blit(floor_surface, (floor_animation + 275,400))pygame.init()screen = pygame.display.set_mode((275,512))clock = pygame.time.Clock()bg_surface = pygame.image.load('C:/Users/cuerv/Downloads/flappy-bird-assets-master/flappy-bird-assets-master/sprites/background-day.png').convert()floor_surface = pygame.image.load('C:/Users/cuerv/Downloads/flappy-bird-assets-master/flappy-bird-assets-master/sprites/base.png').convert()floor_animation = 0bird_surface = pygame.image.load('C:/Users/cuerv/Downloads/flappy-bird-assets-master/flappy-bird-assets-master/sprites/bluebird-midflap.png').convert()bird_rect = bird_surface.get_rect(center = (100,256))while True:? ?? ? for event in pygame.event.get():? ? ? ? if event.type == pygame.QUIT:? ? ? ? ?? ? ? ? ? ? pygame.quit()? ? ? ? ? ? sys.exit()? ? ? ? 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()? ? clock.tick(120)? ? enter code here
查看完整描述

2 回答

?
精慕HU

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í)行的。


查看完整回答
反對 回復 2023-08-22
?
PIPIONE

TA貢獻1829條經(jīng)驗 獲得超9個贊

我猜想在你的函數(shù)中,當鼠標懸停在圖像上或鼠標在時間 t1 的位置!= t2 的位置時,就會發(fā)生動作。還提供代碼,以便我們檢查可能出現(xiàn)的問題:)


查看完整回答
反對 回復 2023-08-22
  • 2 回答
  • 0 關注
  • 248 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號