mercredi 5 mars 2014

pygame - How to group sprites


Vote count:

0




Having a real struggle getting this sorted. Had look at some other answers, and I get an error saying that I have too many arguments.


Class containing the objects I want to add.



class Digimon(pygame.sprite.Sprite):
def __init__(self,age,weight,strength,defence,speed,intelligence, image):
self.age = age
self.weight = weight
self.strength = strength
self.defence = defence
self.speed = speed
self.intelligence = intelligence
self.image = image


Have tried to do:



> class Digimon(pygame.sprite.Sprite):
> def __init__(self):
> pygame.sprite.Sprite.__init__(self,age,weight,strength,defence,speed,intelligence, image)

self.age = age self.weight = weight self.strength = strength self.defence = defence self.speed = speed self.intelligence = intelligence self.image = image


but I error regarding the amount of arguments. (1 given, 7 needed).



Player = Digimon(0,2,0,0,0,0, [pygame.image.load("images/koro_1.png"), pygame.image.load("images/koro_2.png"), pygame.image.load("images/koro_3.png") ] )


This is in example of an object which I want to group together. From this, I'll be able to add keyboard events which affect all the objects grouped.


Any help would be fantastic :D



asked 48 secs ago






Aucun commentaire:

Enregistrer un commentaire