我在其他地方也读过类似的问题,但它说只需将'self‘添加到函数定义中。当我检查文件时它是self,它实际上已经有self关键字了!下面是回溯:
Traceback (most recent call last):
File "C:\Users\Brenda\Documents\The Nick Folder\Mobile Fortress War 3\MFWRT3 - TileClass test\Title.pyw", line 142, in <module>
SelectServer.main()
File "C:\Users\Brenda\Documents\The Nick Folder\Mobile Fortress War 3\MFWRT3 - TileClass test\SelectServer.pyw", line 44, in main
Main.mainloop()
File "C:\Users\Brenda\Documents\The Nick Folder\Mobile Fortress War 3\MFWRT3 - TileClass test\Main.pyw", line 72, in mainloop
globals.alltiles.update()
File "C:\Python32\lib\site-packages\pygame\sprite.py", line 462, in update
s.update(*args)
TypeError: update() takes no arguments (1 given)我这样称呼它:
globals.alltiles.update()有人能帮上忙吗?
发布于 2011-10-13 23:18:16
如果没有要调试的代码,这将是一个猜测游戏,但为了将来的参考,sprite组是这样创建的:
#first create a sprite class
class Card(pygame.sprite.Sprite):
def __init__(self,img,pos):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load(os.path.join('img','cards', img))
self.rect = self.image.get_rect()
self.rect.center = pos
#then create a group
mycards = pygame.sprite.Group()
#then add a sprite to the group
holders.add(Card('ace_spade.jpg',coord))发布于 2013-05-09 18:57:17
我来晚了一点,但这可能是因为每个卡的更新方法声明不正确(我假设这是pygame.sprite.Sprite的子类化)
它应该声明为"def update(self)“,而不是"def update()”
https://stackoverflow.com/questions/7624601
复制相似问题