如何编写步行精灵?

时间:2017-02-02 18:42:08

标签: python pygame sprite python-3.5

我正在研究pygame,我希望受控角色在两个图像之间切换,只要它移动到模拟步行。我现在一直在研究解决方案几个小时,什么都想不到。这是我尝试过的一些代码。

'''Update the visual screen.'''
screen.fill(settings.bg_color)
player.blitme()

player_imagea = pygame.image.load('images/player_imagea.bmp') 
player_imageb = pygame.image.load('images/player_imageb.bmp') 

if player.moving_right and player.image == player_imagea:
    player.image = pygame.image.load('images/player_imageb.bmp')
elif player.moving_right and player.image == player_imageb:
    player.image = pygame.image.load('images/player_imagea.bmp')

#Draw the most recent screen
pygame.display.flip()

除了我已经编程的动作之外,这样做不会发生任何事情。我已经能够让图像切换到第一个按键,但除此之外没什么。

0 个答案:

没有答案
相关问题