我有点麻烦,我想知道你是否可以帮助我解决它 .
所以我've made a sprite and created an idle animation method which I'米这样调用 __init__ 方法 .
class Player(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.attributes = "blah"
self.idleAnimation()
def idleAnimation(self):
self.animationCode = "Works normally I've checked it"
player = Player()
playerGroup = pygame.sprite.Group()
playerGroup.add(player)
window = pygame.display.set_mode(yaddi-yadda)
while StillLooping:
window.fill((0, 0, 0))
playerGroup.update()
playerGroup.draw(window)
pygame.display.flip()
但无论出于何种原因,尽管在 __init__ 方法中调用了idleAnimation方法,但它仍未在组内运行 . 如果我稍后在循环中调用它:
while StillLooping:
player.idleAimation()
window.fill((0, 0, 0))
playerGroup.update()
playerGroup.draw(window)
pygame.display.flip()
它运行,但不是 . 我无法理解为什么 . 任何想法都会非常感谢!