0
切割過的所有不相關的部分,這是我是如何實現它:這是更新pygame中的精靈的最佳方式嗎?
done=False
while(done==False)
#here goes some code for listening to the events
if (some condition fulfilled) then
screen.blit(background, [0,0])
screen.blit(some_sprite,[x,y])
elif (more conditions)
do something else
else
do even more stuff
pygame.display.flip()
如果沒有這個條件語句中後臺更新這個精靈沒有被刪除,當然,操作系統我得到的屏幕上的多個副本。我有強烈的懷疑,這是迄今爲止不是處理這種情況的最佳方式,因爲每次我需要做其他事情都不會改變的圖像看起來像是浪費資源。
我將不勝感激任何建議
你有一種方法可以知道精靈先前佔據了什麼?你可以用'pygame.draw.rect'而不是整個背景 – 2014-09-12 16:01:53
或者根據你的背景'screen.blit(background,[sprite_old_x,sprite_old_y])' – 2014-09-12 16:04:57
來繪製那部分背景,這當然是一個選項。我懷疑這雖然不是最好的方法。我想,應該是涉及精靈陣列的東西。 – Alex 2014-09-12 16:05:07