【发布时间】:2016-06-10 20:51:50
【问题描述】:
我有一个更新图像的主循环:
循环:
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
self.spaceship.buttons()
self.spaceship.update(self.screen)
pygame.display.update()
self.spaceship.buttons() 在哪里:
def buttons(self):
key = pygame.key.get_pressed()
dist = 1
if key[pygame.K_LEFT]:
self.x -= dist
elif key[pygame.K_RIGHT]:
self.x += dist
并定义了self.spaceship.update(self.screen):
def update(self, surface):
surface.blit(self.image, (self.x, self.y))
在主循环更新按键并将图像“blit”到屏幕上之后,它应该更新显示(pygame.display.update()),但屏幕不会被清除。这是移动前后的显示效果:
This is what the image looks like before the blit at a different position
This is what the image looks like after the blit is at a different position (after moving)
为什么pygame.display.update()不清除图片的前几帧?
【问题讨论】: