我正在学习用 pygame 制作游戏,这我不是很熟悉,而且一切都很顺利。最近,我遇到了一个让我感到困惑的错误......
这是给我错误的特定代码...
def draw(self, win):
self.move()
if self.visible:
if self.walkCount + 1 >= 33: # Since we have 11 images for each animtion our upper bound is 33.
# We will show each image for 3 frames. 3 x 11 = 33.
self.walkCount = 0
if self.vel > 0: # If we are moving to the right we will display our walkRight images
win.blit(self.walkRight[self.walkCount // 3], (self.x, self.y))
self.walkCount += 1
else: # Otherwise we will display the walkLeft images
win.blit(self.walkLeft[self.walkCount // 3], (self.x, self.y))
self.walkCount += 1
pygame.draw.rect(win, (255, 0, 0), (self.hitbox[0], self.hitbox[1], -20, 50, 10))
pygame.draw.rect(win, (0, 255, 0), (self.hitbox[0], self.hitbox[1], -20, 50, 10))
self.hitbox = (self.x + 17, self.y + 2, 31, 57)
当我执行我的代码时,我得到这个错误......
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/Users/user/PycharmProjects/Marvel2/Pepe.py", line 215, in <module>
redrawGameWindow()
File "/Users/user/PycharmProjects/Marvel2/Pepe.py", line 133, in redrawGameWindow
goblin.draw(win)
File "/Users/user/PycharmProjects/Marvel2/Pepe.py", line 95, in draw
pygame.draw.rect(win, (255, 0, 0), (self.hitbox[0], self.hitbox[1], -20, 50, 10))
TypeError: Rect argument is invalid
Process finished with exit code 1
谁能帮我?
谢谢!