【发布时间】:2019-10-15 00:37:48
【问题描述】:
我正在 pygame 中制作动画精灵,并且需要帮助找到一种从一个翻转到另一个的方法?当前代码如下所示:
class normal(pygame.sprite.Sprite):
def __init__(self):
#etc, list of images to create the animation
class tall(pygame.sprite.Sprite):
def __init__(self):
#rinse and repeat with a different set of images
我已经知道如何通过按键触发更改。但我不确定要更改哪个变量以及更改什么。当我尝试使用以下代码进行更改时,没有任何反应
fps = 25
pygame.init()
my_sprite = normal()
my_group = pygame.sprite.Group(my_sprite)
#etc until we get to the part where it changes
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
if my_sprite == normal():
my_sprite = tall()
fps = 30
else:
my_sprite = normal()
fps = 25
我不确定我的代码到底有什么问题,因为它不会返回错误。有人能指出我正确的方向吗?
【问题讨论】: