Reputation: 41
I am getting this error
File "main.py", line 48, in update
self.rect = self.rect.move((self.dirx, self.diry))
TypeError: argument must contain two numbers
self is a sprite object that has a rect attribute. In my game, I am trying to move these sprites around by using:
self.rect = self.rect.move((self.dirx, self.diry))
dirx and diry are simply ints between 1 and 3(indicating speed). I have asked multiple peers, but nobody has been able to give me feeback.
EDIT So what was happening was that dirx and diry were getting too large to be considered ints in another method
Upvotes: 1
Views: 4269
Reputation: 41
The problem was that I was incrementing dirx and diry too much in other places and I think they go too large, and it automatically converted to a long.
Upvotes: 1
Reputation: 1
You are returning it as a tuple you need to just return the numbers. Try: self.rect = self.rect.move(self.dirx, self.diry)
Upvotes: 0
Reputation: 2851
Try passing two numbers as two arguments instead of a tuple as shown in the official docs:
move(self.dirx, self.diry)
https://www.pygame.org/docs/ref/rect.html#pygame.Rect.move
Upvotes: 0