2011-10-02 20 views
1

我已經閱讀了其他地方的類似問題,但它只是說要將「self」添加到函數定義中。當我檢查文件是自己的時候,它實際上已經有了self關鍵字!這裏的回溯:Pygame組更新不需要參數

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() 

誰能幫幫忙?

+0

當你只是不要發生什麼」不通過它的一個論點? – John

回答

1

沒有代碼調試這將是一個猜謎遊戲,但以供將來參考,都是這樣產生的精靈羣體:

#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)) 
1

我有點晚,但它是因爲更新的聲明不當可能每張卡的方法(我假設是繼承pygame.sprite.Sprite)

它應該定義爲「高清更新(個體經營)」,而不是「高清更新()」

+0

是的,當我還在學習Python時,這又回來了。 –