我是新來設計Python圖形。我試圖運行下面的代碼,但它給出了一個奇怪的錯誤。有人可以幫我解決這個錯誤嗎?意外的關鍵字參數,'text'
from livewires import games, color
SCREEN_WIDTH=640
SCREEN_HEIGHT=480
my_screen=games.Screen(SCREEN_WIDTH,SCREEN_HEIGHT)
wall_image=games.load_image("wall.jpg", transparent=False)
my_screen.set_background(wall_image)
games.Text(screen=my_screen, x=500, y=30,
text="Score: 1756521", size=50,
colour=color.black)
my_screen.mainloop()
,並在執行此我得到下面的錯誤:
Exception NameError: "global name 'screen' is not defined" in <bound method Text.__del__ of <livewires.games.Text object at 0x02B14810>> ignored
Traceback (most recent call last):
File "C:\Python31\game_test.py", line 9, in <module>
colour=color.black)
TypeError: __init__() got an unexpected keyword argument 'text'
由於事實上,我看着livewires games.py模塊的源代碼,是如下
class Text(Object, ColourMixin):
"""
A class for representing text on the screen.
The reference point of a Text object is the centre of its bounding box.
"""
def __init__(self, screen, x, y, text, size, colour, static=0):
self.init_text (screen, x, y, text, size, colour, static)
.........
那麼我哪裏錯了?
Livewires是可怕的。由於Pygame限制了SDL的功能,它只是限制了Pygame的功能。我最好堅持Pygame。 – 2015-02-08 23:43:55