如何反复制作动画片

时间:2014-06-05 18:29:18

标签: python

我试图将Double Dragon Arcade游戏移植到python上,但是在尝试动画打孔时我遇到了麻烦。按下打孔键(j)时,打孔动画有效。我试着这样做,以便在冲刺后0.5秒,精灵变回常规形态。我使用了sleep命令,但这只是将精灵冻结了0.5秒。我的目标是使它能够连续打击,在0.5秒之后,精灵从打孔动画变回常规动画。

以下是我尝试的代码。 任何帮助将不胜感激。

class BillyLee(games.Sprite):
    image = games.load_image("billyleestill.bmp")
    image2 = games.load_image("billyleestilla.bmp")
    image3 = games.load_image("billypunchr.bmp")
    image4 = games.load_image("billypunchl.bmp")
    punchnumber = 0
    def __init__(self):
        super(BillyLee, self).__init__(image = BillyLee.image,
                                  x = 200,
                                  bottom = 400)    
    def update(self):
        if games.keyboard.is_pressed(games.K_a):
            super(BillyLee, self).__init__(image = BillyLee.image2,
                                           x = self.x,
                                           bottom = self.bottom)
            self.x = self.x - 2
            BillyLee.punchnumber = 1
        if games.keyboard.is_pressed(games.K_d):
            super(BillyLee, self).__init__(image = BillyLee.image,
                                           x = self.x,
                                           bottom = self.bottom) 
            self.x = self.x + 2
            BillyLee.punchnumber = 0
        if games.keyboard.is_pressed(games.K_w):
            self.y = self.y - 2
        if games.keyboard.is_pressed(games.K_s):
            self.y = self.y + 2
        if games.keyboard.is_pressed(games.K_j) and BillyLee.punchnumber == 1:
            super(BillyLee, self).__init__(image = BillyLee.image4,
                                           x = self.x,
                                           bottom = self.bottom)
            #time.sleep(.5)
            super(BillyLee, self).__init__(image = BillyLee.image2,
                                           x = self.x,
                                           bottom = self.bottom)
        if games.keyboard.is_pressed(games.K_j) and BillyLee.punchnumber == 0:
            super(BillyLee, self).__init__(image = BillyLee.image3,
                                           x = self.x,
                                           bottom = self.bottom)




        if self.y > 390:
            self.y = 390
        if self.y < 300:
            self.y = 300
        if self.x < 30:
            self.x = 30

0 个答案:

没有答案