2014-04-27 100 views
0

我只能一次打電話給我的班級。 我的代碼是:在課堂上使用pygame.Surface.blit

class fish: 
    def __init__(self, x, y, image, speed): 
     self.x = x 
     self.y = y 
     self.image = image 
     self.speed = speed 
    def be(self): 
     screen.blit(self.image, (self.x, self.y)) 
     self.x -= self.speed 
     if boot.x+36 > self.x and boot.x < self.x+5: 
      if boot.y+34 > self.y and boot.y < self.y+5: 
       boot.live -= 1 
       boot.x = 100 
       boot.y = 460 
fishes = [] 
fishes.append(fish(900, 300, fish_1, 1)) 

當我打電話內部或外部的遊戲循環(「魚」對象fishes.append(fish(900, 300, fish_1, 1)) 我得到了錯誤:

TypeError: 'fish' object is not callable 
+2

您定義了一個'fish'類,但是在其他地方您創建了一個與之相同的對象我。將該類重命名爲Fish,然後將構造函數調用爲'Fish(900,300,fish_1,1)' –

+0

@BartlomiejLewandowski您應該將您的評論發佈爲答案。 – sloth

回答

1

我的第一個猜測是,你有一條魚變重命名類爲Fish以及構造函數調用Fish(900, 300, fish_1, 1)並且應該沒問題