I am doing a little game, I am new at programming so i wanna start somehow so i have got a game and i want to add animation when you are walking. But i am not able to use more images it is showing me this error. and if you will be open to give me advise for using animation it would be great. I have this (in the important section):
def __init__(self): pygame.sprite.Sprite.__init__(self) self.images = [] for i in range(1, 5): mich = pygame.image.load(os.path.join('images', r'C:/users/filip/documents/rozsireni/Jumpi' r'ng 6.png')).convert() mich2 = pygame.image.load(os.path.join('images', r'C:/users/filip/documents/rozsireni/Jumpi' r'ng 7.png')).convert() mich = pygame.transform.scale(mich, (100, 100)) mich2 = pygame.transform.scale(mich2, (100, 100)) mich.convert_alpha() mich.set_colorkey(ALPHA) mich2.convert_alpha() mich2.set_colorkey(ALPHA) self.images.append(mich, mich2) self.image = self.images[0] self.rect = self.image.get_rect() player = Player() player.rect.x = 300 player.rect.y = 300 player_list = pygame.sprite.Group() player_list.add(player)
Advertisement
Answer
The issue is with list.append
self.images.append(mich, mich2)
You can only append one element at a time, use list.extend([...])
instead if you want to append several elements.