我目前正在用python编写一个更大的程序。这是一个简单的游戏,但我有一个错误。有人能帮我吗?在
错误
Traceback (most recent call last):
File "C:/Users/kkuja/Desktop/game.py", line 36, in <module>
MainWindow.MainLoop()
File "C:/Users/kkuja/Desktop/game.py", line 17, in MainLoop
self.chicken_sprites.draw(self.screen)
File "C:\Users\kkuja\AppData\Local\Programs\Python\Python35\lib\site-packages\pygame\sprite.py", line 475, in draw
self.spritedict[spr] = surface_blit(spr.image, spr.rect)
AttributeError: 'Chicken' object has no attribute 'rect'
编码
^{pr2}$提前谢谢!在
在您代码中的函数
self.chicken_sprites.draw(self.screen)
中,chicken.rect
正试图被访问,但您没有定义它。在如果您参考official documentation,您可以找到代码的和平
您没有在
^{pr2}$Chicken
中设置self.rect
,它应该是这样的。在相关问题 更多 >
编程相关推荐