class combattant(pygame.sprite.Sprite):
def __init__(self,img,posit):
pygame.sprite.Sprite.__init__(self)
self.image=marche[0]
self.image_pos=posit
self.face=0
def mov(self,direction):
if direction[K_LEFT]:
self.face=(self.face+1)%2
self.image_pos.x -= 1
self.image=marche[0+self.face]
print ('gauche')
if direction[K_RIGHT]:
print ("droit")
self.face=(self.face+1)%2
self.image_pos.x += 1
self.image=marche[2+self.face]
combattant.mov (tkey)
Here is my problem , when I run the programme containing this , I get this:
Traceback (most recent call last):
File "F:\ISN\essai 2.py", line 63, in <module>
combattant.mov (tkey)
TypeError: mov() takes exactly 2 arguments (1 given)
Python seems to consider 'self' as argument that I need to give in order for it to work. I have tried using alpha functions or puting an empty space where the self argument is but of course I get an error saying 'Invalid Syntax' and the alpha function doesn't change anything ... Maybe I'm using this the wrong way because I'm a beginner ... It would be very helpfull if someone could help me ! Thank's in advance !
selfis bound when you create an instance and call methods on that. If you are calling methods directly on the class then there is no instance to bind to.combattantfirst, not directly access the methods on the class.imgandpositbe set to?