我正在学习如何使用pygame,并尝试使用同一个精灵的多个图像。我想当我按下键盘上的一个按钮时,精灵的图像会改变。每当我按右箭头键并尝试更改精灵图像时,都会出现错误:
Traceback (most recent call last):
File "C:\Users\theotheo36\workspace\NomadsPie\main.py", line 55, in <module>
game.execute()
File "C:\Users\theotheo36\workspace\NomadsPie\main.py", line 50, in execute
self.render()
File "C:\Users\theotheo36\workspace\NomadsPie\main.py", line 32, in render
self.all.draw(self.screen)
File "C:\Users\theotheo36\Downloads\WinPython-64bit-3.4.4.3Qt5\python-3.4.4.amd64\lib\site-packages\pygame\sprite.py", line 475, in draw
self.spritedict[spr] = surface_blit(spr.image, spr.rect)
TypeError: invalid destination position for blit
这是我的代码:
^{pr2}$
不要忘记在您的
look
方法中self.rect=self.image.get_rect
后面的括号。不带括号self.rect
被分配给函数,而不是返回的矩形。因为它会导致这个矩形的位置错误。在相关问题 更多 >
编程相关推荐