我目前正在在pygame的遊戲,Python 3中,並已給我的問題的代碼的一部分:通過pygame的rotozoom保持透明像素,Python的3
for counter in range(0, 30):
particles = pygame.image.load('particles.png').convert()
particles = pygame.transform.rotozoom(particles, 36*counter, 1.1**counter).convert()
particles.set_colorkey((0, 0, 0, 0))
screen.blit(particles, particles.get_rect(centerx=480, centery=100))
pygame.display.flip()
time.sleep(0.05)
particles.png是隻有透明背景上的幾個彩色像素。問題是,當圖像旋轉和縮放時,其中一些粒子會模糊,導致周圍有大量黑色方塊。
我該如何解決這個問題?提前致謝!!
是關於模糊或透明像素的問題嗎?如果是關於保留透明像素,只需在第3行執行'convert_alpha()'而不是'convert'。如果是關於模糊像素,我不確定是什麼導致了它。 – DJMcMayhem