2012-04-26 19 views
1

Game Over画面に行きたいときにこの問題があります。TypeError: 'pygame.Surface'オブジェクトが呼び出せません

Traceback (most recent call last): 
    File "C:\Users\MO\Desktop\Twerk\ballbounce_changed.py", line 215, in <module> 
    game() 
File "C:\Users\MO\Desktop\Twerk\ballbounce_changed.py", line 191, in game 
    text("Game Over",30,white,300) 
TypeError: 'pygame.Surface' object is not callable 

これが存在画面のコードのセクション:私は、画面上でゲーム内のテキストを削除した場合

while finish == True: 
screen.blit(menu,[0,0]) 
text("Game Over",30,white,300) 
text("Instructions",310,white) 
text("-----------------------------------------------------",320,white) 
text("Avoid the the enemies",340,white) 
text("Last as long as you can!",360,white) 
text("Press space to start",420,white) 

# display.update() 
pygame.display.update() 

for event in pygame.event.get(): 
if event.type == pygame.QUIT: 
    repeat = False 

if event.type == pygame.KEYDOWN: 
    if event.key == pygame.K_SPACE: 
    repeat = True 

if repeat == False: 
pygame.quit() 

else: 
game() 

game() 

、それは仕事をしません。私はテキストを紹介して、私はすぐに私は上記のエラーメッセージを取得

(インデントが正しくない)私はここにインデンとの完全なコードを持っているhttp://pastebin.com/VBkhX4kt

答えて

1

エラーが原因でライン93上にあるありがとうございますファンクションからの変数textのバインドを、font.render()が返すものにオーバーライドします。あなたはそれはあなたが先に定義した関数を呼び出していないtext(...)を呼び出すとき

93: text = font.render('Starting Twerk... ', True, (100,100,100)) 

はこのように、後に、(それが今pygame.Surfaceオブジェクトであるため、それがされていない)呼び出し可能なものとして textを治療しようとしています。

解決策は、その行を変更して、text機能を上書きしないことです。

+0

ありがとう、それは問題です。 – ErHunt

関連する問題